diff --git a/README.md b/README.md index 901e2b77..dc2799a3 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,7 @@ # Xiao [![Build Status](https://travis-ci.org/dragonfire535/xiao.svg?branch=master)](https://travis-ci.org/dragonfire535/xiao) [![Donate on PayPal](https://img.shields.io/badge/paypal-donate-blue.svg)](https://www.paypal.me/dragonfire535) - -> This bot is not available for invite. +[![Discord](https://discordapp.com/api/guilds/252317073814978561/embed.png)](https://discord.gg/mTr83zt) Xiao is a Discord bot coded in JavaScript with [discord.js](https://discord.js.org/) using the @@ -13,6 +12,8 @@ Xiao is a Discord bot coded in JavaScript with ## Table of Contents +- [Invite](#invite) +- [Permissions](#permissions) - [Fun Information](#fun-information) - [Installing](#installing) * [Before You Begin](#before-you-begin) @@ -44,6 +45,35 @@ Xiao is a Discord bot coded in JavaScript with - [Licensing](#licensing) - [Credit](#credit) +## Invite +- [Home Server](https://discord.gg/mTr83zt) +- [Invite](https://discordapp.com/api/oauth2/authorize?client_id=278305350804045834&permissions=104721601&scope=bot) + +## Permissions + +Xiao needs several permissions to be able to do what she does. Below +is every permission Xiao asks for, and what commands you lose if you +don't grant that permission. + +- **Create Instant Invite** is needed to allow owners to join your server to test if needed. + * You lose no commands by turning this off, but you might hinder support. +- **View Audit Log** is not needed yet, but is something Xiao might utilize in the future. +- **Change Nickname** is not _needed_, but is included as a basic permission. +- **View Channels** is required for every single command to work. +- **Send Messages** is required for every single command to work. +- **Manage Messages** allows Xiao to use the `prune` command. +- **Embed Links** is required to allow commands that send embeds to work. Too many commands to list use it. +- **Attach Files** is required to allow commands that send files to work. Too many commands to list use it. +- **Read Message History** allows Xiao to use the `first-message` and `prune` commands. +- **Use External Emojis** allows Xiao to use custom emoji in certain commands. + * While the commands benefit from it, it is not required for the commands to work. +- **Add Reactions** allows Xiao to use commands that add reactions to messages in certain commands. + * While the commands benefit from it, it is not requried for the commands to work. +- **Connect** allows Xiao to join voice channels. It is required for `mafia` to work. +- **Speak** allows Xiao to speak in voice channels. It is required for `mafia` to work. +- **Use Voice Activity** is not needed, but is activiated just in case so `mafia` won't break. + + ## Fun Information - 350+ Commands - 17,000+ lines of JavaScript @@ -92,7 +122,7 @@ Xiao is a Discord bot coded in JavaScript with ## Commands -Total: 363 +Total: 361 ### Utility: @@ -332,8 +362,6 @@ Total: 363 * **battle:** Engage in a turn-based battle against another user or the AI. * **emoji-emoji-revolution:** Can you type arrow emoji faster than anyone else has ever typed them before? * **gunfight:** Engage in a western gunfight against another user. High noon. -* **mafia-role:** Displays your current role during Mafia games. -* **mafia:** Who is the Mafia? Who is the detective? Will the Mafia kill them all? * **quiz-duel:** Answer a series of quiz questions against an opponent. * **russian-roulette:** Who will pull the trigger and die first? * **tic-tac-toe:** Play a game of tic-tac-toe with another user. diff --git a/assets/json/permissions.json b/assets/json/permissions.json new file mode 100644 index 00000000..675d12cf --- /dev/null +++ b/assets/json/permissions.json @@ -0,0 +1,16 @@ +[ + "CREATE_INSTANT_INVITE", + "ADD_REACTIONS", + "VIEW_AUDIT_LOG", + "VIEW_CHANNEL", + "SEND_MESSAGES", + "MANAGE_MESSAGES", + "EMBED_LINKS", + "ATTACH_FILES", + "READ_MESSAGE_HISTORY", + "USE_EXTERNAL_EMOJIS", + "CONNECT", + "SPEAK", + "USE_VAD", + "CHANGE_NICKNAME" +] diff --git a/assets/sounds/mafia/credits.mp3 b/assets/sounds/mafia/credits.mp3 deleted file mode 100644 index 1b791065..00000000 Binary files a/assets/sounds/mafia/credits.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/day-1.mp3 b/assets/sounds/mafia/day-1.mp3 deleted file mode 100644 index 9cc5bd1d..00000000 Binary files a/assets/sounds/mafia/day-1.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/day-10.mp3 b/assets/sounds/mafia/day-10.mp3 deleted file mode 100644 index 5a7929ee..00000000 Binary files a/assets/sounds/mafia/day-10.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/day-11.mp3 b/assets/sounds/mafia/day-11.mp3 deleted file mode 100644 index 6898b8f3..00000000 Binary files a/assets/sounds/mafia/day-11.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/day-12.mp3 b/assets/sounds/mafia/day-12.mp3 deleted file mode 100644 index 7bc8748c..00000000 Binary files a/assets/sounds/mafia/day-12.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/day-2.mp3 b/assets/sounds/mafia/day-2.mp3 deleted file mode 100644 index 56ec910f..00000000 Binary files a/assets/sounds/mafia/day-2.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/day-3.mp3 b/assets/sounds/mafia/day-3.mp3 deleted file mode 100644 index 313a1d51..00000000 Binary files a/assets/sounds/mafia/day-3.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/day-4.mp3 b/assets/sounds/mafia/day-4.mp3 deleted file mode 100644 index 3562f4ef..00000000 Binary files a/assets/sounds/mafia/day-4.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/day-5.mp3 b/assets/sounds/mafia/day-5.mp3 deleted file mode 100644 index 6c7c77a5..00000000 Binary files a/assets/sounds/mafia/day-5.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/day-6.mp3 b/assets/sounds/mafia/day-6.mp3 deleted file mode 100644 index bd8ed46a..00000000 Binary files a/assets/sounds/mafia/day-6.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/day-7.mp3 b/assets/sounds/mafia/day-7.mp3 deleted file mode 100644 index 5786def0..00000000 Binary files a/assets/sounds/mafia/day-7.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/day-8.mp3 b/assets/sounds/mafia/day-8.mp3 deleted file mode 100644 index e05b92fa..00000000 Binary files a/assets/sounds/mafia/day-8.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/day-9.mp3 b/assets/sounds/mafia/day-9.mp3 deleted file mode 100644 index 15f4b5be..00000000 Binary files a/assets/sounds/mafia/day-9.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/detective-decision-made.mp3 b/assets/sounds/mafia/detective-decision-made.mp3 deleted file mode 100644 index 8ed6fdd1..00000000 Binary files a/assets/sounds/mafia/detective-decision-made.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/detective.mp3 b/assets/sounds/mafia/detective.mp3 deleted file mode 100644 index 014ecf50..00000000 Binary files a/assets/sounds/mafia/detective.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/hanged.mp3 b/assets/sounds/mafia/hanged.mp3 deleted file mode 100644 index 746f3b93..00000000 Binary files a/assets/sounds/mafia/hanged.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/init.mp3 b/assets/sounds/mafia/init.mp3 deleted file mode 100644 index 80f0b1fa..00000000 Binary files a/assets/sounds/mafia/init.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/mafia-decision-made.mp3 b/assets/sounds/mafia/mafia-decision-made.mp3 deleted file mode 100644 index 5d4d49e9..00000000 Binary files a/assets/sounds/mafia/mafia-decision-made.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/mafia-loses.mp3 b/assets/sounds/mafia/mafia-loses.mp3 deleted file mode 100644 index 07dbfd53..00000000 Binary files a/assets/sounds/mafia/mafia-loses.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/mafia-wins.mp3 b/assets/sounds/mafia/mafia-wins.mp3 deleted file mode 100644 index 8cdcd494..00000000 Binary files a/assets/sounds/mafia/mafia-wins.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/mafia.mp3 b/assets/sounds/mafia/mafia.mp3 deleted file mode 100644 index dc9fe455..00000000 Binary files a/assets/sounds/mafia/mafia.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/night-1.mp3 b/assets/sounds/mafia/night-1.mp3 deleted file mode 100644 index 2c22d235..00000000 Binary files a/assets/sounds/mafia/night-1.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/night-10.mp3 b/assets/sounds/mafia/night-10.mp3 deleted file mode 100644 index 354d2599..00000000 Binary files a/assets/sounds/mafia/night-10.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/night-11.mp3 b/assets/sounds/mafia/night-11.mp3 deleted file mode 100644 index fd07c807..00000000 Binary files a/assets/sounds/mafia/night-11.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/night-12.mp3 b/assets/sounds/mafia/night-12.mp3 deleted file mode 100644 index 45037cdb..00000000 Binary files a/assets/sounds/mafia/night-12.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/night-2.mp3 b/assets/sounds/mafia/night-2.mp3 deleted file mode 100644 index ad8c9023..00000000 Binary files a/assets/sounds/mafia/night-2.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/night-3.mp3 b/assets/sounds/mafia/night-3.mp3 deleted file mode 100644 index ea66faaf..00000000 Binary files a/assets/sounds/mafia/night-3.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/night-4.mp3 b/assets/sounds/mafia/night-4.mp3 deleted file mode 100644 index 710b68fd..00000000 Binary files a/assets/sounds/mafia/night-4.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/night-5.mp3 b/assets/sounds/mafia/night-5.mp3 deleted file mode 100644 index 0357f12d..00000000 Binary files a/assets/sounds/mafia/night-5.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/night-6.mp3 b/assets/sounds/mafia/night-6.mp3 deleted file mode 100644 index 8be9fe8d..00000000 Binary files a/assets/sounds/mafia/night-6.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/night-7.mp3 b/assets/sounds/mafia/night-7.mp3 deleted file mode 100644 index 0a1907fc..00000000 Binary files a/assets/sounds/mafia/night-7.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/night-8.mp3 b/assets/sounds/mafia/night-8.mp3 deleted file mode 100644 index 139b6d26..00000000 Binary files a/assets/sounds/mafia/night-8.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/night-9.mp3 b/assets/sounds/mafia/night-9.mp3 deleted file mode 100644 index 472ea8e6..00000000 Binary files a/assets/sounds/mafia/night-9.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/no-deceased.mp3 b/assets/sounds/mafia/no-deceased.mp3 deleted file mode 100644 index ef3476e1..00000000 Binary files a/assets/sounds/mafia/no-deceased.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/no-vote.mp3 b/assets/sounds/mafia/no-vote.mp3 deleted file mode 100644 index e8d05fc9..00000000 Binary files a/assets/sounds/mafia/no-vote.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/reveal-deceased.mp3 b/assets/sounds/mafia/reveal-deceased.mp3 deleted file mode 100644 index e230bc6d..00000000 Binary files a/assets/sounds/mafia/reveal-deceased.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/rule-ask.mp3 b/assets/sounds/mafia/rule-ask.mp3 deleted file mode 100644 index a7065462..00000000 Binary files a/assets/sounds/mafia/rule-ask.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/rules.mp3 b/assets/sounds/mafia/rules.mp3 deleted file mode 100644 index 0a714b9a..00000000 Binary files a/assets/sounds/mafia/rules.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/story-1.mp3 b/assets/sounds/mafia/story-1.mp3 deleted file mode 100644 index a5acc444..00000000 Binary files a/assets/sounds/mafia/story-1.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/story-10.mp3 b/assets/sounds/mafia/story-10.mp3 deleted file mode 100644 index 55bf1921..00000000 Binary files a/assets/sounds/mafia/story-10.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/story-11.mp3 b/assets/sounds/mafia/story-11.mp3 deleted file mode 100644 index e242c023..00000000 Binary files a/assets/sounds/mafia/story-11.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/story-12.mp3 b/assets/sounds/mafia/story-12.mp3 deleted file mode 100644 index 884ea169..00000000 Binary files a/assets/sounds/mafia/story-12.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/story-13.mp3 b/assets/sounds/mafia/story-13.mp3 deleted file mode 100644 index 50e929db..00000000 Binary files a/assets/sounds/mafia/story-13.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/story-14.mp3 b/assets/sounds/mafia/story-14.mp3 deleted file mode 100644 index a64bb1d1..00000000 Binary files a/assets/sounds/mafia/story-14.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/story-15.mp3 b/assets/sounds/mafia/story-15.mp3 deleted file mode 100644 index 3bc2a8b2..00000000 Binary files a/assets/sounds/mafia/story-15.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/story-16.mp3 b/assets/sounds/mafia/story-16.mp3 deleted file mode 100644 index 9c12d55c..00000000 Binary files a/assets/sounds/mafia/story-16.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/story-17.mp3 b/assets/sounds/mafia/story-17.mp3 deleted file mode 100644 index 4a533cd9..00000000 Binary files a/assets/sounds/mafia/story-17.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/story-18.mp3 b/assets/sounds/mafia/story-18.mp3 deleted file mode 100644 index bdf1fcdc..00000000 Binary files a/assets/sounds/mafia/story-18.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/story-19.mp3 b/assets/sounds/mafia/story-19.mp3 deleted file mode 100644 index 24919963..00000000 Binary files a/assets/sounds/mafia/story-19.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/story-2.mp3 b/assets/sounds/mafia/story-2.mp3 deleted file mode 100644 index 98f80777..00000000 Binary files a/assets/sounds/mafia/story-2.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/story-20.mp3 b/assets/sounds/mafia/story-20.mp3 deleted file mode 100644 index a8b5983c..00000000 Binary files a/assets/sounds/mafia/story-20.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/story-21.mp3 b/assets/sounds/mafia/story-21.mp3 deleted file mode 100644 index 25487d76..00000000 Binary files a/assets/sounds/mafia/story-21.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/story-3.mp3 b/assets/sounds/mafia/story-3.mp3 deleted file mode 100644 index 13846cfd..00000000 Binary files a/assets/sounds/mafia/story-3.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/story-4.mp3 b/assets/sounds/mafia/story-4.mp3 deleted file mode 100644 index c00df3f0..00000000 Binary files a/assets/sounds/mafia/story-4.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/story-5.mp3 b/assets/sounds/mafia/story-5.mp3 deleted file mode 100644 index ed7c75c4..00000000 Binary files a/assets/sounds/mafia/story-5.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/story-6.mp3 b/assets/sounds/mafia/story-6.mp3 deleted file mode 100644 index f23cae3e..00000000 Binary files a/assets/sounds/mafia/story-6.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/story-7.mp3 b/assets/sounds/mafia/story-7.mp3 deleted file mode 100644 index 3cad1bd3..00000000 Binary files a/assets/sounds/mafia/story-7.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/story-8.mp3 b/assets/sounds/mafia/story-8.mp3 deleted file mode 100644 index a77a24a4..00000000 Binary files a/assets/sounds/mafia/story-8.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/story-9.mp3 b/assets/sounds/mafia/story-9.mp3 deleted file mode 100644 index 98b4e273..00000000 Binary files a/assets/sounds/mafia/story-9.mp3 and /dev/null differ diff --git a/assets/sounds/mafia/vote.mp3 b/assets/sounds/mafia/vote.mp3 deleted file mode 100644 index 609c1243..00000000 Binary files a/assets/sounds/mafia/vote.mp3 and /dev/null differ diff --git a/commands/mp-games/mafia-role.js b/commands/mp-games/mafia-role.js deleted file mode 100644 index 8c5e443d..00000000 --- a/commands/mp-games/mafia-role.js +++ /dev/null @@ -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')); - } -}; diff --git a/commands/mp-games/mafia.js b/commands/mp-games/mafia.js deleted file mode 100644 index a8a24ed6..00000000 --- a/commands/mp-games/mafia.js +++ /dev/null @@ -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!`); - } - } -}; diff --git a/commands/util/info.js b/commands/util/info.js index 62c58fe8..822f77a1 100644 --- a/commands/util/info.js +++ b/commands/util/info.js @@ -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') diff --git a/commands/util/invite.js b/commands/util/invite.js index ab7220c1..e3c93c63 100644 --- a/commands/util/invite.js +++ b/commands/util/invite.js @@ -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: - + Join my home server for support and announcements: + ${this.client.options.invite || 'Coming soon...'} `); } }; diff --git a/package.json b/package.json index 8541316e..2dfe6c0d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "111.1.7", + "version": "112.0.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": { @@ -32,7 +32,6 @@ }, "dependencies": { "@discordjs/collection": "^0.1.5", - "@discordjs/opus": "^0.1.0", "@vitalets/google-translate-api": "^3.0.0", "canvas": "^2.6.1", "cheerio": "^1.0.0-rc.3", diff --git a/structures/mafia/Game.js b/structures/mafia/Game.js deleted file mode 100644 index a9dcac18..00000000 --- a/structures/mafia/Game.js +++ /dev/null @@ -1,118 +0,0 @@ -const Collection = require('@discordjs/collection'); -const path = require('path'); -const { stripIndents } = require('common-tags'); -const Player = require('./Player'); -const { shuffle } = require('../../util/Util'); -const { SUCCESS_EMOJI_ID } = process.env; - -module.exports = class Game { - constructor(client, channel, voiceChannel) { - Object.defineProperty(this, 'client', { value: client }); - - this.name = 'mafia'; - this.players = new Collection(); - this.channel = channel; - this.voiceChannelRaw = voiceChannel; - this.connection = null; - this.dispatcher = null; - this.turn = 1; - } - - determineRoles(playerCount) { - const roles = ['detective', 'mafia', 'mafia']; - for (let i = 0; i < (playerCount - 3); i++) roles.push('innocent'); - return shuffle(roles); - } - - async generate(list) { - const roles = this.determineRoles(list.length); - let i = 0; - for (const user of list) { - try { - await user.send(`You are ${roles[i] === 'detective' ? 'the' : 'a part of the'} **${roles[i]}**.`); - } catch (err) { - await this.channel.send( - `${user}, I couldn't send a DM to you. Please allow DMs and use the \`mafia-role\` command to see your role.` - ); - } - const player = new Player(this, user, roles[i]); - this.players.set(user.id, player); - i++; - } - return this.players; - } - - async init() { - this.connection = await this.voiceChannel.join(); - return this; - } - - end() { - if (this.voiceChannel) this.voiceChannel.leave(); - this.client.games.delete(this.channel.id); - return this; - } - - playAudio(id) { - this.dispatcher = this.connection.play(path.join(__dirname, '..', '..', 'assets', 'sounds', 'mafia', `${id}.mp3`), { - volume: 2 - }); - return new Promise((res, rej) => { - this.dispatcher.once('finish', () => { - this.dispatcher = null; - return res(true); - }); - this.dispatcher.once('error', err => { - this.dispatcher = null; - return rej(err); - }); - }); - } - - async getVotes(playersArr) { - await this.channel.send(stripIndents` - Who do you think is a Mafia member? Please type the number. - ${playersArr.map((p, i) => `**${i + 1}.** ${p.user.tag}`).join('\n')} - `); - const voted = []; - const filter = res => { - if (!this.players.some(p => p.user.id === res.author.id)) return false; - if (voted.includes(res.author.id)) return false; - if (!playersArr[Number.parseInt(res.content, 10) - 1]) return false; - voted.push(res.author.id); - res.react(SUCCESS_EMOJI_ID || '✅').catch(() => null); - return true; - }; - const votes = await this.channel.awaitMessages(filter, { - max: this.players.size, - time: 90000 - }); - if (!votes.size) return null; - return votes; - } - - getHanged(votes, playersArr) { - const counts = new Collection(); - for (const vote of votes.values()) { - const player = this.players.get(playersArr[Number.parseInt(vote.content, 10) - 1].id); - if (counts.has(player.id)) { - ++counts.get(player.id).votes; - } else { - counts.set(player.id, { - id: player.id, - votes: 1, - user: player.user - }); - } - } - return counts.sort((a, b) => b.votes - a.votes).first(); - } - - get shouldEnd() { - return this.players.size < 4 && !this.players.some(p => p.role === 'mafia'); - } - - get voiceChannel() { - return this.connection ? this.connection.channel : this.voiceChannelRaw; - } -}; diff --git a/structures/mafia/Player.js b/structures/mafia/Player.js deleted file mode 100644 index af7a2809..00000000 --- a/structures/mafia/Player.js +++ /dev/null @@ -1,43 +0,0 @@ -const { stripIndents } = require('common-tags'); -const questions = { - mafia: 'Who would you like to kill?', - detective: 'Who do you think is a Mafia member?' -}; - -module.exports = class Player { - constructor(game, user, role) { - this.game = game; - this.user = user; - this.id = user.id; - this.role = role; - } - - toString() { - return this.user.toString(); - } - - async dmRound() { - const valid = Array.from(this.game.players.filter(p => p.role !== this.role).values()); - await this.user.send(stripIndents` - ${questions[this.role]} Please type the number. - ${valid.map((p, i) => `**${i + 1}.** ${p.user.tag}`).join('\n')} - `); - const filter = res => valid[Number.parseInt(res.content, 10) - 1]; - const decision = await this.user.dmChannel.awaitMessages(filter, { - max: 1, - time: 120000 - }); - if (!decision.size) { - await this.user.send('Sorry, time is up!'); - return null; - } - const choice = valid[Number.parseInt(decision.first().content, 10) - 1].id; - if (this.role === 'detective') { - const isMafia = this.game.players.get(choice).role === 'mafia'; - await this.user.send(isMafia ? 'Yes, they are a Mafioso.' : 'No, they are not a Mafioso.'); - } else { - await this.user.send(`**${this.game.players.get(choice).user.tag}** is your choice...`); - } - return choice; - } -};