Public :)

This commit is contained in:
Dragon Fire
2020-03-03 17:48:26 -05:00
parent 8336e33522
commit 5e12926a80
69 changed files with 60 additions and 288 deletions
-22
View File
@@ -1,22 +0,0 @@
const Command = require('../../structures/Command');
module.exports = class MafiaRoleCommand extends Command {
constructor(client) {
super(client, {
name: 'mafia-role',
aliases: ['mafia-me'],
group: 'mp-games',
memberName: 'mafia-role',
description: 'Displays your current role during Mafia games.'
});
}
run(msg) {
const games = this.client.games.filter(game => game.players.has(msg.author.id) && game.name === 'mafia');
if (!games.size) return msg.reply('You aren\'t a member of any games.');
return msg.reply(games.map(game => {
const { role } = game.players.get(msg.author.id);
return `**${game.channel.guild.name} (${game.channel}):** ${role}`;
}).join('\n'));
}
};
-90
View File
@@ -1,90 +0,0 @@
const Command = require('../../structures/Command');
const Game = require('../../structures/mafia/Game');
const { verify } = require('../../util/Util');
const storyCount = 21;
module.exports = class MafiaCommand extends Command {
constructor(client) {
super(client, {
name: 'mafia',
group: 'mp-games',
memberName: 'mafia',
description: 'Who is the Mafia? Who is the detective? Will the Mafia kill them all?',
guildOnly: true,
credit: [
{
name: 'TheMicroKill#9052',
reason: 'Voice Acting'
}
]
});
}
async run(msg) {
const current = this.client.games.get(msg.channel.id);
if (current) return msg.reply(`Please wait until the current game of \`${current.name}\` is finished.`);
const voiceChannel = msg.member.voice.channel;
if (!voiceChannel) return msg.reply('You must be in a voice channel to start a game.');
for (const member of voiceChannel.members.values()) await msg.guild.members.fetch(member.id);
if (voiceChannel.members.size > 15) return msg.reply('Please do not have more than 15 players.');
if (voiceChannel.members.size < 6) return msg.reply('Please have at least 5 players before starting.');
const game = new Game(this.client, msg.channel, voiceChannel);
this.client.games.set(msg.channel.id, game);
try {
await game.init();
await game.generate(voiceChannel.members.filter(m => !m.user.bot).map(m => m.user));
await game.playAudio('init');
await game.playAudio('rule-ask');
await msg.say('Type `yes` to hear a rule explanation.');
const rules = await verify(msg.channel, msg.author);
if (rules) await game.playAudio('rules');
while (!game.shouldEnd) {
let killed = null;
await game.playAudio(`night-${game.turn}`);
await game.playAudio('mafia');
const mafia = game.players.filter(p => p.role === 'mafia');
const choices = await Promise.all(mafia.map(player => player.dmRound()));
const randomizer = choices.filter(c => c !== null);
if (randomizer.length) killed = game.players.get(randomizer[Math.floor(Math.random() * randomizer.length)]);
await game.playAudio('mafia-decision-made');
const detective = game.players.find(p => p.role === 'detective');
if (detective) {
await game.playAudio('detective');
await detective.dmRound();
await game.playAudio('detective-decision-made');
}
await game.playAudio(`day-${game.turn}`);
if (killed) {
const story = Math.floor(Math.random() * storyCount) + 1;
await game.playAudio(`story-${story}`);
await game.playAudio('reveal-deceased');
await msg.say(`Deceased: **${killed}**`);
game.players.delete(killed.id);
} else {
await game.playAudio('no-deceased');
}
await game.playAudio('vote');
const playersArr = Array.from(game.players.values());
const votes = await game.getVotes(playersArr);
if (!votes) {
await game.playAudio('no-votes');
continue;
}
const hanged = game.getHanged(votes, playersArr);
await game.playAudio('hanged');
await msg.say(`Hanged: **${hanged.user}**`);
game.players.delete(hanged.id);
++game.turn;
}
const mafia = game.players.find(p => p.role === 'mafia');
if (mafia) await game.playAudio('mafia-wins');
else await game.playAudio('mafia-loses');
await game.playAudio('credits');
game.end();
return null;
} catch (err) {
game.end();
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+3 -2
View File
@@ -1,10 +1,11 @@
const Command = require('../../structures/Command');
const { MessageEmbed, version: djsVersion, Permissions } = require('discord.js');
const { MessageEmbed, version: djsVersion } = require('discord.js');
const { version: commandoVersion } = require('discord.js-commando');
const moment = require('moment');
require('moment-duration-format');
const { formatNumber } = require('../../util/Util');
const { version, dependencies } = require('../../package');
const permissions = require('../../assets/json/permissions');
const { XIAO_GITHUB_REPO_USERNAME, XIAO_GITHUB_REPO_NAME } = process.env;
const source = XIAO_GITHUB_REPO_NAME && XIAO_GITHUB_REPO_USERNAME;
@@ -22,7 +23,7 @@ module.exports = class InfoCommand extends Command {
}
async run(msg) {
const invite = await this.client.generateInvite(Permissions.ALL);
const invite = await this.client.generateInvite(permissions);
const embed = new MessageEmbed()
.setColor(0x00AE86)
.setFooter('©2017-2020 dragonfire535#8081')
+7 -6
View File
@@ -1,6 +1,6 @@
const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
const { XIAO_GITHUB_REPO_NAME, XIAO_GITHUB_REPO_USERNAME } = process.env;
const permissions = require('../../assets/json/permissions');
module.exports = class InviteCommand extends Command {
constructor(client) {
@@ -14,13 +14,14 @@ module.exports = class InviteCommand extends Command {
});
}
run(msg) {
async run(msg) {
const invite = await this.client.generateInvite(permissions);
return msg.say(stripIndents`
You cannot invite me to your server, but you can join my home server to use me:
${this.client.options.invite || 'Coming soon...'}
Invite me using this link:
<${invite}>
You can also self-host me if you prefer:
<https://github.com/${XIAO_GITHUB_REPO_USERNAME}/${XIAO_GITHUB_REPO_NAME}>
Join my home server for support and announcements:
${this.client.options.invite || 'Coming soon...'}
`);
}
};