From 4b308538961facb87d73fafeab7fab5927562eff Mon Sep 17 00:00:00 2001 From: 8cy <50817549+8cy@users.noreply.github.com> Date: Fri, 10 Apr 2020 10:16:53 -0700 Subject: port to commando/ v12, 2.0.0 ported everything over to v12 and then commando in the span of 2 days no sleep lol. also now using typescript standard for cool 8) --- Cache/DiscordEmoji.json | 1 + app.js | 177 ++++++++----------------- app_temp.js | 143 -------------------- commands/8ball.js | 19 --- commands/abee.js | 25 ---- commands/botstatus.js | 95 ------------- commands/clear.js | 46 ------- commands/commands.js | 32 ----- commands/dm.js | 68 ---------- commands/emoji.js | 10 -- commands/fart.js | 95 ------------- commands/fun/8ball.js | 30 +++++ commands/fun/dm.js | 39 ++++++ commands/fun/emoji.js | 21 +++ commands/fun/quote.js | 29 ++++ commands/fun/say.js | 26 ++++ commands/help.js | 38 ------ commands/itemshop.js | 25 ---- commands/join.js | 15 --- commands/leave.js | 13 -- commands/membercount.js | 8 -- commands/ping.js | 22 ---- commands/psycho.js | 24 ---- commands/quote.js | 18 --- commands/reboot.js | 26 ---- commands/say.js | 11 -- commands/server.js | 26 ---- commands/squeak.js | 20 --- commands/uhhhh.js | 21 --- commands/uptime.js | 8 -- commands/utility/clear.js | 62 +++++++++ commands/utility/membercount.js | 21 +++ commands/utility/reboot.js | 40 ++++++ commands/utility/server.js | 38 ++++++ commands/utility/uptime.js | 24 ++++ commands/voice/abee.js | 32 +++++ commands/voice/fart.js | 73 ++++++++++ commands/voice/itemshop.js | 36 +++++ commands/voice/join.js | 28 ++++ commands/voice/leave.js | 30 +++++ commands/voice/loop.js | 29 ++++ commands/voice/pause.js | 28 ++++ commands/voice/play.js | 286 ++++++++++++++++++++++++++++++++++++++++ commands/voice/psycho.js | 31 +++++ commands/voice/queue.js | 29 ++++ commands/voice/remove.js | 38 ++++++ commands/voice/resume.js | 28 ++++ commands/voice/shuffle.js | 49 +++++++ commands/voice/skip.js | 25 ++++ commands/voice/skipall.js | 29 ++++ commands/voice/skipto.js | 39 ++++++ commands/voice/squeak.js | 27 ++++ commands/voice/uhhhh.js | 28 ++++ commands/voice/volume.js | 38 ++++++ commands/voice/wahoo.js | 28 ++++ commands/volume.js | 15 --- commands/wahoo.js | 21 --- config.json | 11 +- docs/help_embed_format.js | 34 ----- package.json | 7 +- utils/bot_voice_check.js | 7 - utils/no_args.js | 7 - utils/no_command.js | 7 - utils/perms.js | 7 - utils/user_voice_check.js | 7 - utils/voice_check.js | 19 +++ utils/voice_check_dialog.js | 11 -- 67 files changed, 1340 insertions(+), 1060 deletions(-) create mode 100644 Cache/DiscordEmoji.json delete mode 100644 app_temp.js delete mode 100644 commands/8ball.js delete mode 100644 commands/abee.js delete mode 100644 commands/botstatus.js delete mode 100644 commands/clear.js delete mode 100644 commands/commands.js delete mode 100644 commands/dm.js delete mode 100644 commands/emoji.js delete mode 100644 commands/fart.js create mode 100644 commands/fun/8ball.js create mode 100644 commands/fun/dm.js create mode 100644 commands/fun/emoji.js create mode 100644 commands/fun/quote.js create mode 100644 commands/fun/say.js delete mode 100644 commands/help.js delete mode 100644 commands/itemshop.js delete mode 100644 commands/join.js delete mode 100644 commands/leave.js delete mode 100644 commands/membercount.js delete mode 100644 commands/ping.js delete mode 100644 commands/psycho.js delete mode 100644 commands/quote.js delete mode 100644 commands/reboot.js delete mode 100644 commands/say.js delete mode 100644 commands/server.js delete mode 100644 commands/squeak.js delete mode 100644 commands/uhhhh.js delete mode 100644 commands/uptime.js create mode 100644 commands/utility/clear.js create mode 100644 commands/utility/membercount.js create mode 100644 commands/utility/reboot.js create mode 100644 commands/utility/server.js create mode 100644 commands/utility/uptime.js create mode 100644 commands/voice/abee.js create mode 100644 commands/voice/fart.js create mode 100644 commands/voice/itemshop.js create mode 100644 commands/voice/join.js create mode 100644 commands/voice/leave.js create mode 100644 commands/voice/loop.js create mode 100644 commands/voice/pause.js create mode 100644 commands/voice/play.js create mode 100644 commands/voice/psycho.js create mode 100644 commands/voice/queue.js create mode 100644 commands/voice/remove.js create mode 100644 commands/voice/resume.js create mode 100644 commands/voice/shuffle.js create mode 100644 commands/voice/skip.js create mode 100644 commands/voice/skipall.js create mode 100644 commands/voice/skipto.js create mode 100644 commands/voice/squeak.js create mode 100644 commands/voice/uhhhh.js create mode 100644 commands/voice/volume.js create mode 100644 commands/voice/wahoo.js delete mode 100644 commands/volume.js delete mode 100644 commands/wahoo.js delete mode 100644 docs/help_embed_format.js delete mode 100644 utils/bot_voice_check.js delete mode 100644 utils/no_args.js delete mode 100644 utils/no_command.js delete mode 100644 utils/perms.js delete mode 100644 utils/user_voice_check.js create mode 100644 utils/voice_check.js delete mode 100644 utils/voice_check_dialog.js diff --git a/Cache/DiscordEmoji.json b/Cache/DiscordEmoji.json new file mode 100644 index 0000000..4046fd2 --- /dev/null +++ b/Cache/DiscordEmoji.json @@ -0,0 +1 @@ +{"Categories":"{\"1\":\"Original Style\",\"18\":\"Recolors\",\"2\":\"TV \\/ Movie\",\"10\":\"Gaming\",\"3\":\"Meme\",\"4\":\"Anime\",\"13\":\"Pepe\",\"5\":\"Celebrity\",\"6\":\"Blobs\",\"7\":\"Thinking\",\"17\":\"Animals\",\"15\":\"Cute\",\"11\":\"Letters\",\"14\":\"Logos\",\"16\":\"Utility\",\"12\":\"Other\",\"8\":\"Animated\",\"9\":\"NSFW\"}"} \ No newline at end of file diff --git a/app.js b/app.js index 9409ed7..697a3b6 100644 --- a/app.js +++ b/app.js @@ -1,137 +1,66 @@ -// TODO: add pause, resume and volume - -const fs = require('fs'); -const Discord = require('discord.js'); const config = require('./config.json'); -const bot = new Discord.Client(); -bot.commands = new Discord.Collection(); -bot.utils = new Discord.Collection(); -const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js')); -for (const file of commandFiles) { - const command = require(`./commands/${file}`); - - bot.commands.set(command.name, command); -} -const utilFiles = fs.readdirSync('./utils').filter(file => file.endsWith('.js')); -for (const file of utilFiles) { - const util = require(`./utils/${file}`); +const { CommandoClient } = require('discord.js-commando'); +const path = require('path'); +const { Structures } = require('discord.js'); +Structures.extend('Guild', Guild => { + class MusicGuild extends Guild { + constructor(client, data) { + super(client, data); + this.musicData = { + queue: [], + isPlaying: false, + volume: 1, + songDispatcher: null + }; + } + } + return MusicGuild; +}); - bot.utils.set(util.name, util); -} +const client = new CommandoClient({ + commandPrefix: 's5n!', + owner: '217348698294714370' +}); -bot.on('ready', () => { - console.log(`Started bot: ${bot.user.tag} (ID: ${bot.user.id})\nCurrently running on ${bot.guilds.size} server(s).`); // Startup dialouge in output console - bot.user.setActivity('psycho~ uwu', { +client.registry + .registerDefaultTypes() + .registerGroups([ + ['fun', 'fun command group'], + ['moderation', 'moderation command group'], + ['utility', 'utility command group'], + ['voice', 'voice command group'] + ]) + .registerDefaultGroups() + .registerDefaultCommands({ + help: false + }) + .registerCommandsIn(path.join(__dirname, 'commands')); + +client.once('ready', () => { + console.log(`Started bot: ${client.user.tag} (ID: ${client.user.id})\nCurrently running on ${client.guilds.cache.size} server(s).`); + client.user.setActivity('psycho~ uwu', { type: 'LISTENING' }); }); -bot.on('error', console.error); - -bot.on('message', async msg => { - //if (msg.channel.name === 'bots' || msg.channel.name === 'bot-commands' || msg.member.hasPermission('KICK_MEMBERS')) { - if (msg.author.bot) { - // Debugging to see if the bot has an influence on the commands having an error - //console.log('bot message picked up'); - return; - } else { - // Constants for uptime command - const upTime = require('moment'); - require('moment-duration-format'); - const duration = upTime.duration(bot.uptime).format(" D [days], H [hrs], m [mins], s [secs]"); +client.on('error', console.error); - // Command usage info for logs - var msgContent = msg.content.toLowerCase(); - if (prefixCheck()) { - console.log(msg.member.user.tag, 'says', msgContent, 'in #' + msg.channel.name); +client.on('message', async msg => { + // When someone uses a command, it console.log's it + function prefixCheck() { + if (msgContent.startsWith('s5n!')) { + return true; } + } + var msgContent = msg.content.toLowerCase(); + if (prefixCheck()) { + console.log(msg.member.user.tag, 'says', msgContent, 'in #' + msg.channel.name); + } - // Check if message has a prefix in it from config.json - function prefixCheck() { - if (msgContent.startsWith(config.prefixes.main)) { - return "main"; - } else if (msgContent.startsWith(config.prefixes.alt)) { - return "alt1"; - } else if (msgContent.startsWith(config.prefixes.alt2)) { - return "alt2"; - } else if (msgContent.startsWith(config.prefixes.alt3)) { - return "alt3"; - } else if (msgContent.startsWith(config.prefixes.alt4)) { - return "alt4"; - } else if (msgContent.startsWith(config.prefixes.alt5)) { - return "alt5"; - } else if (msgContent.startsWith(config.prefixes.alt6)) { - return "alt6"; - } else if (msgContent.startsWith(config.prefixes.alt6b)) { - return "alt6b"; - } - } - - if (prefixCheck() == "main") { - var args = msg.content.slice(config.prefixes.main.length).split(/ +/); - var command = args.shift().toLowerCase(); - - if (msg.author.bot || !msg.content.startsWith(config.prefixes.main)) return; - } else if (prefixCheck() == "alt1") { - var args = msg.content.slice(config.prefixes.alt.length).split(/ +/); - var command = args.shift().toLowerCase(); - - if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt)) return; - } else if (prefixCheck() == "alt2") { - var args = msg.content.slice(config.prefixes.alt2.length).split(/ +/); - var command = args.shift().toLocaleLowerCase(); - - if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt2)) return; - } else if (prefixCheck() == "alt3") { - var args = msg.content.slice(config.prefixes.alt3.length).split(/ +/); - var command = args.shift().toLocaleLowerCase(); - - if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt3)) return; - } else if (prefixCheck() == "alt4") { - var args = msg.content.slice(config.prefixes.alt4.length).split(/ +/); - var command = args.shift().toLocaleLowerCase(); - - if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt4)) return; - } else if (prefixCheck() == "alt5") { - var args = msg.content.slice(config.prefixes.alt4.length).split(/ +/); - var command = args.shift().toLocaleLowerCase(); - - if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt4)) return; - } else if (prefixCheck() == "alt6") { - var args = msg.content.slice(config.prefixes.alt4.length).split(/ +/); - var command = args.shift().toLocaleLowerCase(); - - if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt4)) return; - } else if (prefixCheck() == "alt6b") { - var args = msg.content.slice(config.prefixes.alt4b.length).split(/ +/); - var command = args.shift().toLocaleLowerCase(); - - if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt4b)) return; - } - - // Reacts with ping emoji when @everyone - if (msg.mentions.everyone) { - msg.react(':ArisaPing:695887537390223402'); - } - - // Cooldown check - // TODO: implament cooldowns when needed https://discordjs.guide/command-handling/adding-features.html#cooldowns - - // Main commands try/ catch - try { - const cmd = bot.commands.get(command) || bot.commands.find(c => c.aliases && c.aliases.includes(command)); - - if (!cmd) return; - cmd.execute(msg, args, bot, duration); - return; - } catch (error) { - console.error(error); - msg.reply('command error\'d out, check logs. also, how did u manage to break it lol'); - return; - } - //} else if (msg.channel.name !== 'bots' && msg.content.startsWith(`${config.prefixes.main}`) && !msg.member.hasPermission('KICK_MEMBERS')) return; + // Reacts with ping emoji when @everyone + if (msg.mentions.everyone) { + msg.react(':ArisaPing:695887537390223402'); } }); -// Get bot token -bot.login(config['secret']); \ No newline at end of file +client.login(config['secret']); \ No newline at end of file diff --git a/app_temp.js b/app_temp.js deleted file mode 100644 index abbb40a..0000000 --- a/app_temp.js +++ /dev/null @@ -1,143 +0,0 @@ -const Discord = require('discord.js'); -const config = require('./config.json'); -const bot = new Discord.Client(); -const isImageUrl = require('is-image-url'); -const emoji = require('emoji-random'); -const atquotes = require('at-quotes'); -const ytdl = require('ytdl-core'); - -bot.on('ready', () => { - console.log(`Started bot: ${bot.user.tag} (ID: ${bot.user.id})\nCurrently running on ${bot.guilds.size} server(s).`); // Startup dialouge in output console - bot.user.setActivity('psycho~ uwu', { // Set status - type: 'LISTENING' - }); - - // Outputs available commands in output console - //commands = ['bot', 'help']; - //console.log(commands); -}); - -// Outputs errors in console window -bot.on('error', console.error); - -// Start Bot Commands -bot.on('message', async msg => { - //console.log(msg.content.toLowerCase()); - if (msg.channel.name === 'bots' || msg.channel.name === 'bot-commands' || msg.member.hasPermission('KICK_MEMBERS')) { - var msgContent = msg.content.toLowerCase(); - if (prefixCheck()) { - console.log(msg.member.user.tag, 'says', msgContent, 'in #' + msg.channel.name); - } - //console.log(config.prefixes.main); - - // Check prefixies in config.json - function prefixCheck() { - if (msgContent.startsWith(config.prefixes.main)) { - return "main"; - } else if (msgContent.startsWith(config.prefixes.alt)) { - return "alt1"; - } else if (msgContent.startsWith(config.prefixes.alt2)) { - return "alt2"; - } else if (msgContent.startsWith(config.prefixes.alt3)) { - return "alt3"; - } else if (msgContent.startsWith(config.prefixes.alt4)) { - return "alt4"; - } else if (msgContent.startsWith(config.prefixes.alt5)) { - return "alt5"; - } else if (msgContent.startsWith(config.prefixes.alt6)) { - return "alt6"; - } else if (msgContent.startsWith(config.prefixes.alt6b)) { - return "alt6b"; - } - } - - if (prefixCheck() == "main") { - var args = msg.content.slice(config.prefixes.main.length).split(/ +/); - var command = args.shift().toLowerCase(); - - if (msg.author.bot || !msg.content.startsWith(config.prefixes.main)) return; - } else if (prefixCheck() == "alt1") { - var args = msg.content.slice(config.prefixes.alt.length).split(/ +/); - var command = args.shift().toLowerCase(); - - if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt)) return; - } else if (prefixCheck() == "alt2") { - var args = msg.content.slice(config.prefixes.alt2.length).split(/ +/); - var command = args.shift().toLocaleLowerCase(); - - if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt2)) return; - } else if (prefixCheck() == "alt3") { - var args = msg.content.slice(config.prefixes.alt3.length).split(/ +/); - var command = args.shift().toLocaleLowerCase(); - - if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt3)) return; - } else if (prefixCheck() == "alt4") { - var args = msg.content.slice(config.prefixes.alt4.length).split(/ +/); - var command = args.shift().toLocaleLowerCase(); - - if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt4)) return; - } else if (prefixCheck() == "alt5") { - var args = msg.content.slice(config.prefixes.alt4.length).split(/ +/); - var command = args.shift().toLocaleLowerCase(); - - if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt4)) return; - } else if (prefixCheck() == "alt6") { - var args = msg.content.slice(config.prefixes.alt4.length).split(/ +/); - var command = args.shift().toLocaleLowerCase(); - - if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt4)) return; - } else if (prefixCheck() == "alt6b") { - var args = msg.content.slice(config.prefixes.alt4b.length).split(/ +/); - var command = args.shift().toLocaleLowerCase(); - - if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt4b)) return; - } - - function noArgs() { - msg.channel.send(`invalid argument(s). type \`${config.prefixes.main}help\` for more information.`); - } - - function noCommand() { - msg.channel.send(`invalid or unspecified command. type \`${config.prefixes.main}help\`.`); - } - - function perms(p) { - if (msg.member.hasPermission(p)) return true; - } - - /*if (command == 'botstatus' || command == 'status' || command == 'bs') { - if (msg.member.hasPermission('KICK_MEMBERS')) { - if (!args) { - msg.reply('no status specified') - } - - if (args == 'online') { - bot.user.setStatus("online"); - } else if (args == 'idle') { - bot.user.setStatus("idle"); - } else if (args == 'dnd') { - bot.user.setStatus("dnd"); - } else if (args == 'invisable') { - bot.user.setStatus("invisable"); - } - } else { - msg.reply('insufficent perms bruh'); - } - }*/ - - /*function joinCheck() { - switch (msg.guild.voiceConnection) { - case !msg.guild.voiceConnection && msg.member.voiceChannel: - msg.member.voiceChannel.join(); - msg.reply('succesfully joined voice channel') - case (msg.guild.voiceConnection): - msg.reply('i\'m already in voice channel') - case (!msg.member.voiceChannel): - msg.reply('you\'re not in a voice channel') - } - }*/ - } else if (msg.channel.name !== 'bots' && msg.content.startsWith(`${config.prefixes.main}`) && !msg.member.hasPermission('KICK_MEMBERS')) return; -}) - -// Get bot token -bot.login(config['secret']) \ No newline at end of file diff --git a/commands/8ball.js b/commands/8ball.js deleted file mode 100644 index 878fc92..0000000 --- a/commands/8ball.js +++ /dev/null @@ -1,19 +0,0 @@ -const Discord = require('discord.js'); - -module.exports = { - name: '8ball', - aliases: ['ball', '8b', 'eightball', 'eightb'], - description: '', - execute(msg) { - r = ['yes~ uwu', 'no.', 'yes!', 'no!', 'what, no.', 'yes.', 'maybe.', 'perhaps.', 'try again.', 'i\'m not sure.']; - - var s = r[Math.floor(Math.random() * r.length)]; - - emb = new Discord.RichEmbed() - - .setAuthor('the 8-ball says', 'https://upload.wikimedia.org/wikipedia/commons/thumb/f/fd/8-Ball_Pool.svg/500px-8-Ball_Pool.svg.png') - .setDescription('`' + s + '`'); - - msg.channel.send(RichEmbed = emb); - } -}; \ No newline at end of file diff --git a/commands/abee.js b/commands/abee.js deleted file mode 100644 index ced7c10..0000000 --- a/commands/abee.js +++ /dev/null @@ -1,25 +0,0 @@ -const ytdl = require('ytdl-core'); -const voice_check_dialog = require('../utils/voice_check_dialog.js'); - -module.exports = { - name: 'abee', - aliases: ['a-bee'], - description: '', - async execute(msg, args, bot) { - if (msg.member.voiceChannel && !msg.guild.voiceConnection) { - const connection = await msg.member.voiceChannel.join(); - const stream = ytdl('https://www.youtube.com/watch?v=lvdnhWhQBdo', { - filter: 'audioonly' - }); - const dispatcher = connection.playStream(stream, { - volume: 0.5 - }); - - dispatcher.on('end', () => { - msg.member.voiceChannel.leave(); - }); - } else { - voice_check_dialog.execute(msg); - } - } -}; \ No newline at end of file diff --git a/commands/botstatus.js b/commands/botstatus.js deleted file mode 100644 index da2c85a..0000000 --- a/commands/botstatus.js +++ /dev/null @@ -1,95 +0,0 @@ -// TODO: bot status - -const Discord = require('discord.js'); - -module.exports = { - name: 'botstatus', - aliases: ['status', 'bs'], - description: '', - async execute(msg, args, bot) { - if (msg.member.hasPermission('KICK_MEMBERS')) { - var activityType = bot.user.presence.game.type; - var activityName = bot.user.presence.game.name; - - function activityTypeToWords() { - if (activityName == '0') { - var activityName = 'PLAYING'; - } else if (activityName == '1') { - var activityName = 'STREAMING'; - } else if (activityName == '2') { - var activityName = 'LISTENING'; - } else if (activityName == '3') { - var activityName = 'WATCHING'; - } - } - - if (args[0] == 'reset' || args[0] == 'r') { - bot.user.setActivity('psycho ~uwu', { - type: 'LISTENING' - }); - msg.reply('status has been reset lol'); - } else if (args[0] == 'format' || args[0] == 'f') { - // Print full, proper format for the Discord.js setActivity() function - msg.reply('\n`' + bot.user.setActivity.toString() + '`'); - } else if (args[0] == 'message' || args[0] == 'msg' || args[0] == 'm') { - // This took way to long to complete lol, 2020/04/08, 00:12, my birthday lol - if (args[0] == 'message') { - var m = args.join(' '); - var mf = m.slice(8, 22); - } else if (args[0] == 'msg') { - var m = args.join(' '); - var mf = m.slice(4, 22); - } else if (args[0] == 'm') { - var m = args.join(' '); - var mf = m.slice(2, 22); - } - - if (mf == 'reset' || mf == 'r') { - bot.user.setActivity('psycho ~uwu', { - type: activityType - }); - - msg.reply('status message has been reset lol'); - } else { - bot.user.setActivity(mf, { - type: activityType - }); - } - } else if (args[0] == 'type' || args[0] == 't') { - var m = args[1]; - args[1].toLowerCase(); - if (args[1] == 'playing' || args[1] == 'p') { - var m = 'playing'; - - bot.user.setActivity(activityName, { - type: m - }); - } else if (args[1] == 'listening' || args[1] == 'l') { - var m = 'LISTENING'; - - bot.user.setActivity(activityName, { - type: m - }); - } else if (args[1] == 'watching' || args[1] == 'w') { - var m = 'WATCHING'; - - bot.user.setActivity(activityName, { - type: m - }); - } else if (args[1] == 'custom' || args[1] == 'c') { - msg.reply('custom status is disabled due to discord api policies about self-botting :('); - } else if (args[1] == 'reset' || args[1] == 'r') { - bot.user.setActivity(activityName, { - type: 'LISTENING' - }); - - msg.reply('status type has been reset lol'); - } - } else if (!args.length) { - msg.reply('no arguments specified'); - } - } else { - msg.reply('insufficent perms bruh'); - } - } -}; \ No newline at end of file diff --git a/commands/clear.js b/commands/clear.js deleted file mode 100644 index fe8e46f..0000000 --- a/commands/clear.js +++ /dev/null @@ -1,46 +0,0 @@ -module.exports = { - name: 'clear', - aliases: ['delete', 'del', 'c'], - description: '', - async execute(msg, args, bot) { - if (msg.member.hasPermission('MANAGE_MESSAGES')) { - if (!args) { - msg.reply('you haven\'t specified an amount of messages which should be deleted.').then(deleteNotificationMessage => { - deleteNotificationMessage.delete(1000); - }); - } else if (isNaN(args)) { - msg.reply('the amount parameter isn\'t a number.').then(deleteNotificationMessage => { - deleteNotificationMessage.delete(1000); - }); - } else if (args > 100) { - msg.reply('you can\'t delete more than 100 messages at once.').then(deleteNotificationMessage => { - deleteNotificationMessage.delete(1000); - }); - } else if (args < 1) { - msg.reply('you have to delete at least 1 message.').then(deleteNotificationMessage => { - deleteNotificationMessage.delete(1000); - }); - } - /*else if (msg.createdTimestamp > 1209600) { - msg.reply('due to discord rules, bots can only bulk delete messages that are under 14 days old :(') - } */ - else { - var clearAmount = parseInt(args[0]) + 1; - // It took me so long to figure out why this was not really working. It would delete but an insane amount at a time. - // I realized that because it was getting parsed as a string, it would just add 1 to it so if I tried to delete 1 - // message, it would delete 11 lol. Fixed by parsing as integer THEN adding one. 02:30 2020/04/03/2020 - - await msg.channel.fetchMessages({ - limit: clearAmount - }).then(messages => { // I am on v11 discord.js - msg.channel.bulkDelete(messages); - }); - msg.reply('it\'s been deleted ~uwu').then(deleteNotificationMessage => { - deleteNotificationMessage.delete(1000); - }); - } - } else { - msg.reply('insufficent perms bruh'); - } - } -}; \ No newline at end of file diff --git a/commands/commands.js b/commands/commands.js deleted file mode 100644 index 47af2e6..0000000 --- a/commands/commands.js +++ /dev/null @@ -1,32 +0,0 @@ -const Discord = require('discord.js'); - -module.exports = { - name: 'commands', - description: '', - execute(msg, args, bot) { - let emb = new Discord.RichEmbed() - - .setAuthor('s5nical\'s commands', `${msg.guild.iconURL}`) - .setThumbnail(`${msg.guild.iconURL}`) - .setDescription(`to view the commands in each group use:\n\`s5n!commands \``) - .addField(`:shield: moderation`, '13 commands.', true) - .addField(`:robot: automation`, '5 commands.', true) - .addField(`:gem: features`, '8 commands.', true) - .addField(`:lock: permissions`, '10 commands.', true) - .addField(`:mag_right: search`, '14 commands.', true) - .addField(`:wrench: utlity`, '20 commands.', true) - .addField(`:information_source: information`, '6 commands.', true) - .addField(`:smirk: fun`, '17 commands.', true) - .addField(`:moneybag: economy`, '8 commands.', true) - .addField(`:game_die: gambling`, '3 commands.', true) - .addField(`:smiley: profiles`, '4 commands.', true) - .addField(`:hammer_pick: skills`, '4 commands.', true) - .addField(`:frame_photo: image`, '3 commands.', true) - .addField(`:blue_heart: reaction`, '8 commands.', true) - .addField(`:chart_with_upwards_trend: counter`, '9 commands.', true) - .addField(`:sailboat: ship`, '2 commands.', true) - .setColor(0xF97DAE); - - msg.channel.send(RichEmbed = emb); - } -}; \ No newline at end of file diff --git a/commands/dm.js b/commands/dm.js deleted file mode 100644 index ccc757c..0000000 --- a/commands/dm.js +++ /dev/null @@ -1,68 +0,0 @@ -const Discord = require('discord.js'); - -module.exports = { - name: 'dm', - aliases: ['directmessage'], - description: '', - execute(msg, args, bot) { - if (msg.author) { // TODO: fix discord not evaluating args[1] - if (!msg.mentions.users.first() && !args[1]) { - msg.reply('you haven\'t specified a user or a message.'); - } else if (!args[1]) { - msg.reply('you haven\'t specified anything to send.'); - } else if (!msg.mentions.users) { - msg.reply('you haven\'t specified anyone to send a dm to.'); - } else { - var sendTo = msg.mentions.users.first().id; - var d = new Date(msg.createdTimestamp); - - msg.guild.fetchMember(sendTo, false).then(messageUser => { - messageUser.send(args[1]); - - let emb = new Discord.RichEmbed() - - .addField(`message`, args[1], true) - .addField(`recipient`, msg.mentions.users.first(), true) - .addField(`time sent`, d) - .setColor(0xF97DAE); - - msg.channel.send(RichEmbed = emb); - }); - } - - // This shit took about an hour and a half to debug because I couldn't figure out how to convert the first arguement into - // a user id. After getting help from discord.js Discord I fixed it for about 30 seconds at 21:26 and then I broke it again instantlly - // after. Then I tried to fix everything and I almost broke everything again but I realized it was broken because I did s5n!dm instead - // of s5n!test and I hadn't ported the code over from test to. 2020/04/02, 21:34 - //where sendTo and d went - //args[0] = args[0].id - //msg.reply(args[0]); - // args[0]; - - // msg.reply(typeof args[0]) // for debugging - - // const collector = new Discord.MessageCollector(msg.channel, m => m.author.id === msg.author.id, { - // time: 5000 - // }); - // msg.reply('timed out', 5000) - // //console.log(collector) - - // collector.on('collect', message => { - // var messageText = message.content; - - // if (msg.member.message) { - // msg.reply('received') - // } - // }) - - // msg.reply('what would you like to say?'); - // if (msg.member.lastMessage) { - // var messageText = msg.member.lastMessage.content; - // } - - // where send function went - } else { - msg.reply('insufficent perms bruh'); - } - } -}; \ No newline at end of file diff --git a/commands/emoji.js b/commands/emoji.js deleted file mode 100644 index 5724895..0000000 --- a/commands/emoji.js +++ /dev/null @@ -1,10 +0,0 @@ -const emoji = require('emoji-random'); - -module.exports = { - name: 'emoji', - aliases: ['moji'], - description: '', - execute(msg, args, bot) { - msg.reply(emoji.random()); - } -}; \ No newline at end of file diff --git a/commands/fart.js b/commands/fart.js deleted file mode 100644 index d2fbeb5..0000000 --- a/commands/fart.js +++ /dev/null @@ -1,95 +0,0 @@ -const voice_check_dialog = require('../utils/voice_check_dialog.js'); -const bot_voice_check = require('../utils/bot_voice_check.js'); - -module.exports = { - name: 'fart', - aliases: ['f'], - description: '', - async execute(msg, args, bot) { - if (args[0] == 'long' || args[0] == 'longest' || args[0] == 'l') { - if (msg.member.voiceChannel && !msg.guild.voiceConnection) { - const connection = await msg.member.voiceChannel.join(); - const dispatcher = connection.playFile('./assets/audio/longest_fart_ever.mp3', { - volume: 1.0 - }); - - dispatcher.on('end', () => { - msg.member.voiceChannel.leave(); - }); - } else { - voice_check_dialog.execute(msg); - } - } else if (msg.member.voiceChannel && !msg.guild.voiceConnection) { - const connection = await msg.member.voiceChannel.join(); - var fartNum = Math.floor((Math.random() * 8) + 1); - - if (fartNum == 1) { - msg.reply('you got fart 1, courtesy of Sin'); - const dispatcher = connection.playFile('./assets/audio/farts/1.mp3', { - volume: 0.5 - }); - dispatcher.on('end', () => { - msg.member.voiceChannel.leave(); - }); - } else if (fartNum == 2) { - msg.reply('you got fart 2, courtesy of Sin'); - const dispatcher = connection.playFile('./assets/audio/farts/2.mp3', { - volume: 0.5 - }); - dispatcher.on('end', () => { - msg.member.voiceChannel.leave(); - }); - } else if (fartNum == 3) { - msg.reply('you got fart 3, courtesy of Sin'); - const dispatcher = connection.playFile('./assets/audio/farts/3.mp3', { - volume: 0.5 - }); - dispatcher.on('end', () => { - msg.member.voiceChannel.leave(); - }); - } else if (fartNum == 4) { - msg.reply('you got fart 4, courtesy of Sin'); - const dispatcher = connection.playFile('./assets/audio/farts/4.mp3', { - volume: 0.5 - }); - dispatcher.on('end', () => { - msg.member.voiceChannel.leave(); - }); - } else if (fartNum == 5) { - msg.reply('you got fart 5, courtesy of Sin'); - const dispatcher = connection.playFile('./assets/audio/farts/5.mp3', { - volume: 0.5 - }); - dispatcher.on('end', () => { - msg.member.voiceChannel.leave(); - }); - } else if (fartNum == 6) { - msg.reply('you got fart 6, courtesy of nick'); - const dispatcher = connection.playFile('./assets/audio/farts/6.mp3', { - volume: 0.5 - }); - dispatcher.on('end', () => { - msg.member.voiceChannel.leave(); - }); - } else if (fartNum == 7) { - msg.reply('you got fart 7, courtesy of nick'); - const dispatcher = connection.playFile('./assets/audio/farts/7.mp3', { - volume: 0.5 - }); - dispatcher.on('end', () => { - msg.member.voiceChannel.leave(); - }); - } else if (fartNum == 8) { - msg.reply('you got fart 8, courtesy of nick'); - const dispatcher = connection.playFile('./assets/audio/farts/8.mp3', { - volume: 0.5 - }); - dispatcher.on('end', () => { - msg.member.voiceChannel.leave(); - }); - } - } else { - voice_check_dialog.execute(msg); - } - } -}; \ No newline at end of file diff --git a/commands/fun/8ball.js b/commands/fun/8ball.js new file mode 100644 index 0000000..c5702f1 --- /dev/null +++ b/commands/fun/8ball.js @@ -0,0 +1,30 @@ +const { Command } = require('discord.js-commando'); +const { MessageEmbed } = require('discord.js'); + +module.exports = class EightBallFun extends Command { + constructor(client) { + super(client, { + name: '8ball', + aliases: ['8b'], + group: 'fun', + memberName: '8ball', + description: 'shake the 8ball 4 a fortune', + throttling: { + usages: 5, + duration: 30 + } + }); + } + + run(msg) { + var r = ['yes~ uwu', 'no.', 'yes!', 'no!', 'what, no.', 'yes.', 'maybe.', 'perhaps.', 'try again.', 'i\'m not sure.']; + var s = r[Math.floor(Math.random() * r.length)]; + + let embed = new MessageEmbed() + + .setAuthor('the 8-ball says', 'https://upload.wikimedia.org/wikipedia/commons/thumb/f/fd/8-Ball_Pool.svg/500px-8-Ball_Pool.svg.png') + .setDescription('`' + s + '`'); + + msg.channel.send(embed); + } +}; \ No newline at end of file diff --git a/commands/fun/dm.js b/commands/fun/dm.js new file mode 100644 index 0000000..472af1e --- /dev/null +++ b/commands/fun/dm.js @@ -0,0 +1,39 @@ +const { Command } = require('discord.js-commando'); +const { RichEmbed } = require('demojijs'); + +module.exports = class DMFun extends Command { + constructor(client) { + super(client, { + name: 'dm', + aliases: ['directmessage', 'direct-message'], + group: 'fun', + memberName: 'dm', + description: 'dm someone', + guildOnly: true, + args: [ + { + key: 'msgContent', + prompt: 'what would u like to send', + type: 'string' + } + ] + }); + } + run(msg, { msgContent }) { + if (msg.author) { + if (!msg.mentions.users.first() && msgContent) { + msg.reply('you haven\'t specified anyone to send a dm to.'); + } else { + var sendTo = msg.mentions.users.first().id; + var d = new Date(msg.createdTimestamp); + + msg.guild.members.fetch(sendTo, false).then(messageUser => { + messageUser.send(msgContent); + msg.reply('sent :D'); + }); + } + } else { + msg.reply('insufficent perms bruh'); + } + } +}; \ No newline at end of file diff --git a/commands/fun/emoji.js b/commands/fun/emoji.js new file mode 100644 index 0000000..ab3e47c --- /dev/null +++ b/commands/fun/emoji.js @@ -0,0 +1,21 @@ +const emoji = require('emoji-random'); +const { Command } = require('discord.js-commando'); + +module.exports = class EmojiFun extends Command { + constructor(client) { + super(client, { + name: 'emoji', + aliases: ['moji'], + group: 'fun', + memberName: 'emoji', + description: 'gives u a random emoji', + throttling: { + usages: 5, + duration: 30 + } + }); + } + run(msg) { + msg.reply(emoji.random()); + } +}; \ No newline at end of file diff --git a/commands/fun/quote.js b/commands/fun/quote.js new file mode 100644 index 0000000..2496ef3 --- /dev/null +++ b/commands/fun/quote.js @@ -0,0 +1,29 @@ +const atquotes = require('at-quotes'); +const { Command } = require('discord.js-commando'); + +module.exports = class QuoteFun extends Command { + constructor(client) { + super(client, { + name: 'quote', + aliases: ['quotes'], + group: 'fun', + memberName: 'quote', + description: 'gives you a random quote from adventure time', + throttling: { + usages: 5, + duration: 30 + } + }); + } + run(msg, args) { + if (!args.length) { + msg.reply(atquotes.getQuote()); + } else if (args[0] == 'finn') { + msg.reply(atquotes.getFinnQuote()); + } else if (args[0] == 'jake') { + msg.reply(atquotes.getJakeQuote()); + } else if (args[0] == 'ice-king') { + msg.reply(atquotes.getIceKingQuote()); + } + } +}; \ No newline at end of file diff --git a/commands/fun/say.js b/commands/fun/say.js new file mode 100644 index 0000000..cb344c9 --- /dev/null +++ b/commands/fun/say.js @@ -0,0 +1,26 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class SayFun extends Command { + constructor(client) { + super(client, { + name: 'say', + group: 'fun', + memberName: 'say', + description: 'speak as the bot', + guildOnly: true, + args: [ + { + key: 'say', + prompt: 'u cant send an empty msg lol', + type: 'string' + } + ] + }); + } + run(msg, { say }) { + if (msg.member.hasPermission('KICK_MEMBERS')) { + msg.channel.send(say); + msg.delete(); + } + } +}; \ No newline at end of file diff --git a/commands/help.js b/commands/help.js deleted file mode 100644 index 27436e1..0000000 --- a/commands/help.js +++ /dev/null @@ -1,38 +0,0 @@ -const Discord = require('discord.js'); - -module.exports = { - name: 'help', - aliases: ['h'], - description: '', - execute(msg, args, bot) { - if (!args.length) { - let emb = new Discord.RichEmbed() - - .setThumbnail(`${msg.guild.iconURL}`) - .setDescription(` - **command list**\nlink not yet set lol\n\n**categories list:**\n\`s5n!help \`\n\n**full list**\n\`s5n!commands\` - `) - .setColor(0xF97DAE); - - msg.channel.send(RichEmbed = emb); - } else if (args[0] == 'quotes' || args[0] == 'quote') { - let emb = new Discord.RichEmbed() - - .setTitle('quotes -> quote command: (server only)') - .setThumbnail(`${msg.guild.iconURL}`) - .setDescription(`says random quote from adventure time`) - .addField('details', `says random quote from adventure time -no argument: says a quote from any of the adventure time characters. -finn: says a quote from finn from adventure time. -jake: says a quote from jake from adventure time. -ice-king: says a quote from ice king from adventure time.`, false) - .addField(`format`, `\`s5n!quote [finn | jake | ice-king]\``, true) - .addField('examples', `\`s5n!quote\` - says a random quote any of the adventure time characters -\`s5n!quote finn\` - says a quote from finn from adventure time`, false) - .setFooter('<> - required, | - either/or, {} - optional') - .setColor(0xF97DAE); - - msg.channel.send(RichEmbed = emb); - } - } -}; \ No newline at end of file diff --git a/commands/itemshop.js b/commands/itemshop.js deleted file mode 100644 index b05cb2c..0000000 --- a/commands/itemshop.js +++ /dev/null @@ -1,25 +0,0 @@ -const ytdl = require('ytdl-core'); - -module.exports = { - name: 'itemshop', - aliases: ['is'], - description: '', - async execute(msg, args, bot) { - if (msg.member.voiceChannel && !msg.guild.voiceConnection) { - const connection = await msg.member.voiceChannel.join(); - const stream = ytdl('https://www.youtube.com/watch?v=pBiI1hTwU7E', { - filter: 'audioonly' - }); - const dispatcher = connection.playStream(stream, { - volume: 0.5 - }); - - // dispatcher.time >= 6000 - dispatcher.on('end', () => { - msg.member.voiceChannel.leave(); - }); - } else { - voice_check_dialog.execute(msg); - } - } -}; \ No newline at end of file diff --git a/commands/join.js b/commands/join.js deleted file mode 100644 index b07e6c7..0000000 --- a/commands/join.js +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = { - name: 'join', - aliases: ['j'], - description: '', - execute(msg, args, bot) { - if (!msg.guild.voiceConnection && msg.member.voiceChannel) { - msg.member.voiceChannel.join(); - msg.reply('succesfully joined voice channel'); - } else if (msg.guild.voiceConnection) { - msg.reply('i\'m already in voice channel'); - } else if (!msg.member.voiceChannel) { - msg.reply('you\'re not in a voice channel'); - } - } -}; \ No newline at end of file diff --git a/commands/leave.js b/commands/leave.js deleted file mode 100644 index 03701be..0000000 --- a/commands/leave.js +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = { - name: 'leave', - aliases: ['l'], - description: '', - execute(msg, args, bot) { - if (msg.guild.voiceConnection) { - msg.guild.voiceConnection.disconnect(); - msg.reply('succesfully left voice channel'); - } else { - msg.reply('i\'m not in a voice channel'); - } - } -}; \ No newline at end of file diff --git a/commands/membercount.js b/commands/membercount.js deleted file mode 100644 index 8edc030..0000000 --- a/commands/membercount.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - name: 'membercount', - aliases: ['memberc', 'mcount', 'mc'], - description: '', - execute(msg, args, bot) { - msg.reply(`there are **${msg.guild.memberCount}** members in **${msg.guild.name}**`); - } -}; \ No newline at end of file diff --git a/commands/ping.js b/commands/ping.js deleted file mode 100644 index 69526eb..0000000 --- a/commands/ping.js +++ /dev/null @@ -1,22 +0,0 @@ -const Discord = require('discord.js'); - -module.exports = { - name: 'ping', - aliases: ['p'], - description: '', - execute(msg, args, bot) { - const t = Date.now(); - - msg.channel.send('plz wait..').then(m => { - m.edit(`** **`); - - const n = Date.now(); - let emb = new Discord.RichEmbed() - - .setDescription(`pong! s5nical's is \`${n - t}ms\`. heartbeat \`${bot.ping}ms\`.`) - .setColor(0xF97DAE); - - msg.channel.send(RichEmbed = emb); - }); - } -}; \ No newline at end of file diff --git a/commands/psycho.js b/commands/psycho.js deleted file mode 100644 index 13bca98..0000000 --- a/commands/psycho.js +++ /dev/null @@ -1,24 +0,0 @@ -const ytdl = require('ytdl-core'); -const voice_check_dialog = require('../utils/voice_check_dialog.js'); - -module.exports = { - name: 'psycho', - description: '', - async execute(msg, args, bot) { - if (msg.member.voiceChannel && !msg.guild.voiceConnection) { - const connection = await msg.member.voiceChannel.join(); - const stream = ytdl('https://www.youtube.com/watch?v=fnd_HSmAODs', { - filter: 'audioonly' - }); - const dispatcher = connection.playStream(stream, { - volume: 0.5 - }); - - dispatcher.on('end', () => { - msg.member.voiceChannel.leave(); - }); - } else { - voice_check_dialog.execute(msg); - } - } -}; \ No newline at end of file diff --git a/commands/quote.js b/commands/quote.js deleted file mode 100644 index e7cdbf9..0000000 --- a/commands/quote.js +++ /dev/null @@ -1,18 +0,0 @@ -const atquotes = require('at-quotes'); - -module.exports = { - name: 'quote', - aliases: ['quotes', 'q'], - description: '', - execute(msg, args, bot) { - if (!args.length) { - msg.reply(atquotes.getQuote()); - } else if (args[0] == 'finn') { - msg.reply(atquotes.getFinnQuote()); - } else if (args[0] == 'jake') { - msg.reply(atquotes.getJakeQuote()); - } else if (args[0] == 'ice-king') { - msg.reply(atquotes.getIceKingQuote()); - } - } -}; \ No newline at end of file diff --git a/commands/reboot.js b/commands/reboot.js deleted file mode 100644 index b4eb7f6..0000000 --- a/commands/reboot.js +++ /dev/null @@ -1,26 +0,0 @@ -const bvc = require('../utils/bot_voice_check.js'); - -module.exports = { - name: 'reboot', - aliases: ['r', 're'], - description: '', - execute(msg, args, bot) { - if (args[0] == 'voice' || args[0] == 'v') { - if (!msg.member.voiceChannel) { - msg.reply('you need to be in a voice channel to reboot the voice module'); - } else if (!bvc.execute(msg)) { - msg.member.voiceChannel.join(); - msg.member.voiceChannel.leave(); - msg.reply('voice module reboot finished lol'); - } else if (bvc.execute(msg)) { - msg.member.voiceChannel.leave(); - msg.member.voiceChannel.join(); - msg.reply('voice module reboot finished lol'); - } - } else if (args[0] == 'commands' || args[0] == 'commands' || args[0] == 'cmds' || args[0] == 'cmd' || args[0] == 'c') { - msg.reply('commands module reboot finished lol'); - } else if (!args.length) { - msg.reply('no module(s) specified'); - } - } -}; \ No newline at end of file diff --git a/commands/say.js b/commands/say.js deleted file mode 100644 index a27558f..0000000 --- a/commands/say.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - name: 'say', - description: '', - execute(msg, args, bot) { - if (msg.member.hasPermission('KICK_MEMBERS')) { - m = args.join(' '); - msg.channel.send(m); - msg.delete(); - } - } -}; \ No newline at end of file diff --git a/commands/server.js b/commands/server.js deleted file mode 100644 index c410243..0000000 --- a/commands/server.js +++ /dev/null @@ -1,26 +0,0 @@ -const Discord = require('discord.js'); - -module.exports = { - name: 'server', - aliases: ['serverinfo', 'si'], - description: '', - execute(msg) { - var o = msg.guild.members.filter(m => m.presence.status === 'online').size; - - emb = new Discord.RichEmbed() - - .setAuthor(`${msg.guild.name} - ${msg.guild.id}`, `${msg.guild.iconURL}`, `https://discordapp.com/channels/${msg.guild.id}/${msg.guild.id}`) - .setDescription(`here\'s all the information on \`${msg.guild.name}\``) - .setThumbnail(`${msg.guild.iconURL}`) - .addField('owner', `${msg.guild.owner}`, false) - .addField(`members [${msg.guild.memberCount}]`, `${o} members are online.`, true) - .addField('region', `${msg.guild.region}`, true) - .addField('text channels', `${msg.guild.channels.filter(c => c.type === 'text').size}`, true) - .addField('voice channels', `${msg.guild.channels.filter(c => c.type === 'voice').size}`, true) - .addField('guild created', `${msg.guild.createdAt}`, false) - .addField('s5nical joined', `${msg.guild.members.get('695107550403756192').joinedAt}`) - .setColor(0xF97DAE); - - msg.channel.send(RichEmbed = emb); - } -}; \ No newline at end of file diff --git a/commands/squeak.js b/commands/squeak.js deleted file mode 100644 index fef4520..0000000 --- a/commands/squeak.js +++ /dev/null @@ -1,20 +0,0 @@ -const voice_check_dialog = require('../utils/voice_check_dialog.js'); - -module.exports = { - name: 'squeak', - description: '', - async execute(msg, args, bot) { - if (msg.member.voiceChannel && !msg.guild.voiceConnection) { - const connection = await msg.member.voiceChannel.join(); - const dispatcher = connection.playFile('./assets/audio/squeak.wav', { - volume: 0.2 - }); - - dispatcher.on('end', () => { - msg.member.voiceChannel.leave(); - }); - } else { - voice_check_dialog.execute(msg); - } - } -}; \ No newline at end of file diff --git a/commands/uhhhh.js b/commands/uhhhh.js deleted file mode 100644 index e4d0330..0000000 --- a/commands/uhhhh.js +++ /dev/null @@ -1,21 +0,0 @@ -const voice_check_dialog = require('../utils/voice_check_dialog.js'); - -module.exports = { - name: 'uhhhh', - aliases: ['moan'], - description: '', - async execute(msg, args, bot) { - if (msg.member.voiceChannel && !msg.guild.voiceConnection) { - const connection = await msg.member.voiceChannel.join(); - const dispatcher = connection.playFile('./assets/audio/uhhhh.wav', { - volume: 0.5 - }); - - dispatcher.on('end', () => { - msg.member.voiceChannel.leave(); - }); - } else { - voice_check_dialog.execute(msg); - } - } -}; \ No newline at end of file diff --git a/commands/uptime.js b/commands/uptime.js deleted file mode 100644 index f6dbefd..0000000 --- a/commands/uptime.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - name: 'uptime', - aliases: ['ut'], - description: '', - async execute(msg, args, bot, duration) { - msg.reply(duration); - } -}; \ No newline at end of file diff --git a/commands/utility/clear.js b/commands/utility/clear.js new file mode 100644 index 0000000..61f9fbb --- /dev/null +++ b/commands/utility/clear.js @@ -0,0 +1,62 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class ClearUtility extends Command { + constructor(client) { + super(client, { + name: 'clear', + aliases: ['delete', 'del', 'c'], + group: 'utility', + memberName: 'clear', + description: 'clear an ammount of messages', + guildOnly: true, + args: [ + { + key: 'deleteAmount', + prompt: 'how many messages would u like to delete?', + type: 'integer' + } + ] + }); + } + async run(msg, { deleteAmount }) { + if (msg.member.hasPermission('MANAGE_MESSAGES')) { + if (!deleteAmount) { + msg.reply('you haven\'t specified an amount of messages which should be deleted.').then(deleteNotificationMessage => { + deleteNotificationMessage.delete({ timeout: 1000 }); + }); + } else if (isNaN(deleteAmount)) { + msg.reply('the amount parameter isn\'t a number.').then(deleteNotificationMessage => { + deleteNotificationMessage.delete({ timeout: 1000 }); + }); + } else if (deleteAmount > 100) { + msg.reply('you can\'t delete more than 100 messages at once.').then(deleteNotificationMessage => { + deleteNotificationMessage.delete({ timeout: 1000 }); + }); + } else if (deleteAmount < 1) { + msg.reply('you have to delete at least 1 message.').then(deleteNotificationMessage => { + deleteNotificationMessage.delete({ timeout: 1000 }); + }); + } + /*else if (msg.createdTimestamp > 1209600) { + msg.reply('due to discord rules, bots can only bulk delete messages that are under 14 days old :(') + } */ + else { + var clearAmount = deleteAmount + 1; + // It took me so long to figure out why this was not really working. It would delete but an insane amount at a time. + // I realized that because it was getting parsed as a string, it would just add 1 to it so if I tried to delete 1 + // message, it would delete 11 lol. Fixed by parsing as integer THEN adding one. 02:30 2020/04/03/2020 + + await msg.channel.messages.fetch({ + limit: clearAmount + }).then(messages => { // I am on v11 discord.js + msg.channel.bulkDelete(messages); + }); + msg.reply('it\'s been deleted ~uwu').then(deleteNotificationMessage => { + deleteNotificationMessage.delete({ timeout: 1000 }); + }); + } + } else { + msg.reply('insufficent perms bruh'); + } + } +}; \ No newline at end of file diff --git a/commands/utility/membercount.js b/commands/utility/membercount.js new file mode 100644 index 0000000..4ec7978 --- /dev/null +++ b/commands/utility/membercount.js @@ -0,0 +1,21 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class MemberCountUtility extends Command { + constructor(client) { + super(client, { + name: 'membercount', + aliases: ['memberc', 'mcount', 'mc'], + group: 'utility', + memberName: 'membercount', + description: 'says how many members there are in the server', + throttling: { + usages: 5, + duration: 30 + }, + guildOnly: true + }); + } + run(msg) { + msg.reply(`there are **${msg.guild.memberCount}** members in **${msg.guild.name}**`); + } +}; \ No newline at end of file diff --git a/commands/utility/reboot.js b/commands/utility/reboot.js new file mode 100644 index 0000000..031ff08 --- /dev/null +++ b/commands/utility/reboot.js @@ -0,0 +1,40 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class RebootUtility extends Command { + constructor(client) { + super(client, { + name: 'reboot', + aliases: ['r', 're'], + group: 'utility', + memberName: 'reboot', + description: 'reboots a module(s)', + guildOnly: true, + args: [ + { + key: 'module', + prompt: 'which module(s) would you like to reboot?', + type: 'integer' + } + ] + }); + } + run(msg, { module }) { + if (module == 'voice' || module == 'v') { + if (!msg.member.voice.channel) { + msg.reply('you need to be in a voice channel to reboot the voice module'); + } else if (!msg.guild.voice) { + msg.member.voice.channel.join(); + msg.member.voice.channel.leave(); + msg.reply('voice module reboot finished lol'); + } else if (msg.guild.voice) { + msg.member.voice.channel.leave(); + msg.member.voice.channel.join(); + msg.reply('voice module reboot finished lol'); + } + } else if (module == 'commands' || module == 'commands' || module == 'cmds' || module == 'cmd' || module == 'c') { + msg.reply('commands module reboot finished lol'); + } else if (!args.length) { + msg.reply('no module(s) specified'); + } + } +}; \ No newline at end of file diff --git a/commands/utility/server.js b/commands/utility/server.js new file mode 100644 index 0000000..0269eba --- /dev/null +++ b/commands/utility/server.js @@ -0,0 +1,38 @@ +const { Command } = require('discord.js-commando'); +const { MessageEmbed } = require('discord.js'); + +module.exports = class ServerUtility extends Command { + constructor(client) { + super(client, { + name: 'server', + aliases: ['serverinfo', 'si'], + group: 'utility', + memberName: 'server', + description: 'gives u info about the server', + throttling: { + usages: 2, + duration: 60 + }, + guildOnly: true + }); + } + run(msg) { + var o = msg.guild.members.filter(m => m.presence.status === 'online').size; // TODO: fix online people not working + + let embed = new MessageEmbed() + + .setAuthor(`${msg.guild.name} - ${msg.guild.id}`, `${msg.guild.iconURL()}`, `https://discordapp.com/channels/${msg.guild.id}/${msg.guild.id}`) + .setDescription(`here\'s all the information on \`${msg.guild.name}\``) + .setThumbnail(`${msg.guild.iconURL()}`) + .addField('owner', `${msg.guild.owner}`, false) + .addField(`members [${msg.guild.memberCount}]`, `${o} members are online.`, true) + .addField('region', `${msg.guild.region}`, true) + .addField('text channels', `${msg.guild.channels.filter(c => c.type === 'text').size}`, true) + .addField('voice channels', `${msg.guild.channels.filter(c => c.type === 'voice').size}`, true) + .addField('guild created', `${msg.guild.createdAt}`, false) + .addField('s5nical joined', `${msg.guild.members.get('695107550403756192').joinedAt}`) + .setColor(0xF97DAE); + + msg.channel.send(embed); + } +}; \ No newline at end of file diff --git a/commands/utility/uptime.js b/commands/utility/uptime.js new file mode 100644 index 0000000..1fe86e9 --- /dev/null +++ b/commands/utility/uptime.js @@ -0,0 +1,24 @@ +const { Command } = require('discord.js-commando'); +const upTime = require('moment'); +require('moment-duration-format'); + +module.exports = class UptimeUtility extends Command { + constructor(client) { + super(client, { + name: 'uptime', + aliases: ['ut'], + group: 'utility', + memberName: 'uptime', + description: 'tells you how long the bot has been online', + throttling: { + usages: 5, + duration: 30 + }, + guildOnly: true + }); + } + run(msg) { + const duration = upTime.duration(this.client.uptime).format(" D [days], H [hrs], m [mins], s [secs]"); + msg.reply(duration); + } +}; \ No newline at end of file diff --git a/commands/voice/abee.js b/commands/voice/abee.js new file mode 100644 index 0000000..80f9df9 --- /dev/null +++ b/commands/voice/abee.js @@ -0,0 +1,32 @@ +const ytdl = require('ytdl-core'); +const { Command } = require('discord.js-commando'); + +module.exports = class ABeeVoice extends Command { + constructor(client) { + super(client, { + name: 'abee', + aliases: ['a-bee'], + group: 'voice', + memberName: 'abee', + description: 'a bee :D 🐝', + guildOnly: true + }); + } + async run(msg) { + if (msg.member.voice.channel && !msg.guild.voice) { + const connection = await msg.member.voice.channel.join(); + const stream = ytdl('https://www.youtube.com/watch?v=lvdnhWhQBdo', { + filter: 'audioonly' + }); + const dispatcher = connection.play(stream); + + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } else if (msg.guild.voice) { + msg.reply('i\'m already playing that lol'); + } else { + msg.reply('you need to join a voice channel first silly'); + } + } +}; \ No newline at end of file diff --git a/commands/voice/fart.js b/commands/voice/fart.js new file mode 100644 index 0000000..f5b1dfd --- /dev/null +++ b/commands/voice/fart.js @@ -0,0 +1,73 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class FartVoice extends Command { + constructor(client) { + super(client, { + name: 'fart', + group: 'voice', + memberName: 'fart', + description: 'gives you a random fart', + guildOnly: true + }); + } + async run(msg) { + if (msg.member.voice.channel && !msg.guild.voice) { + const connection = await msg.member.voice.channel.join(); + var fartNum = Math.floor((Math.random() * 8) + 1); + + if (fartNum == 1) { + msg.reply('you got fart 1, courtesy of Sin'); + const dispatcher = connection.play('./assets/audio/farts/1.mp3'); + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } else if (fartNum == 2) { + msg.reply('you got fart 2, courtesy of Sin'); + const dispatcher = connection.play('./assets/audio/farts/2.mp3'); + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } else if (fartNum == 3) { + msg.reply('you got fart 3, courtesy of Sin'); + const dispatcher = connection.play('./assets/audio/farts/3.mp3'); + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } else if (fartNum == 4) { + msg.reply('you got fart 4, courtesy of Sin'); + const dispatcher = connection.play('./assets/audio/farts/4.mp3'); + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } else if (fartNum == 5) { + msg.reply('you got fart 5, courtesy of Sin'); + const dispatcher = connection.play('./assets/audio/farts/5.mp3'); + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } else if (fartNum == 6) { + msg.reply('you got fart 6, courtesy of nick'); + const dispatcher = connection.play('./assets/audio/farts/6.mp3'); + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } else if (fartNum == 7) { + msg.reply('you got fart 7, courtesy of nick'); + const dispatcher = connection.play('./assets/audio/farts/7.mp3'); + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } else if (fartNum == 8) { + msg.reply('you got fart 8, courtesy of nick'); + const dispatcher = connection.play('./assets/audio/farts/8.mp3'); + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } + } else if (msg.guild.voice) { + msg.reply('i\'m already playing that lol'); + } else { + msg.reply('you need to join a voice channel first silly'); + } + } +}; \ No newline at end of file diff --git a/commands/voice/itemshop.js b/commands/voice/itemshop.js new file mode 100644 index 0000000..6550604 --- /dev/null +++ b/commands/voice/itemshop.js @@ -0,0 +1,36 @@ +const ytdl = require('ytdl-core'); +const { Command } = require('discord.js-commando'); + +module.exports = class ItemShopVoice extends Command { + constructor(client) { + super(client, { + name: 'itemstop', + aliases: ['is'], + group: 'voice', + memberName: 'itemstop', + description: 'use code frozen in the itemshop', + guildOnly: true + }); + } + async run(msg) { + if (msg.member.voice.channel && !msg.guild.voice) { + const connection = await msg.member.voice.channel.join(); + const stream = ytdl('https://www.youtube.com/watch?v=pBiI1hTwU7E', { + filter: 'audioonly' + }); + const dispatcher = connection.play(stream); + msg.reply('USE CODE FROZEN IN THE FORTNITE ITEM SHOP!!!'); + + function timeCheck() { + if (dispatcher.streamTime >= 6000) { + connection.disconnect(); + } + } + setInterval(timeCheck, 500); + } else if (msg.guild.voice) { + msg.reply('i\'m already playing that lol'); + } else { + msg.reply('you need to join a voice channel first silly'); + } + } +}; \ No newline at end of file diff --git a/commands/voice/join.js b/commands/voice/join.js new file mode 100644 index 0000000..0445390 --- /dev/null +++ b/commands/voice/join.js @@ -0,0 +1,28 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class JoinVoice extends Command { + constructor(client) { + super(client, { + name: 'join', + aliases: ['j'], + group: 'voice', + memberName: 'join', + description: 'joins your voice channel', + throttling: { + usages: 2, + duration: 5 + }, + guildOnly: true + }); + } + run(msg) { + if (!msg.guild.voice && msg.member.voice.channel) { + msg.member.voice.channel.join(); + msg.reply('succesfully joined voice channel'); + } else if (msg.guild.voice) { + msg.reply('i\'m already in voice channel'); + } else if (!msg.member.voice.channel) { + msg.reply('you\'re not in a voice channel'); + } + } +}; \ No newline at end of file diff --git a/commands/voice/leave.js b/commands/voice/leave.js new file mode 100644 index 0000000..13009eb --- /dev/null +++ b/commands/voice/leave.js @@ -0,0 +1,30 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class LeaveVoice extends Command { + constructor(client) { + super(client, { + name: 'leave', + aliases: ['end', 'stop'], + group: 'voice', + memberName: 'leave', + description: 'stops voice channel if any playing', + guildOnly: true + }); + } + run(msg) { + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('join a channel and try again'); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('there isn\'t a song playing right now lol'); + } + if (!msg.guild.musicData.queue) + return msg.say('there are no songs in queue rn lol'); + msg.guild.musicData.songDispatcher.end(); + msg.guild.musicData.queue.length = 0; + return; + } +}; \ No newline at end of file diff --git a/commands/voice/loop.js b/commands/voice/loop.js new file mode 100644 index 0000000..64c586e --- /dev/null +++ b/commands/voice/loop.js @@ -0,0 +1,29 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class LoopVoice extends Command { + constructor(client) { + super(client, { + name: 'loop', + group: 'voice', + memberName: 'loop', + description: 'loops currently playing audio', + guildOnly: true + }); + } + run(msg) { + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('join a channel and try again'); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('there isn\'t a song playing right now lol'); + } + msg.channel.send( + `${msg.guild.musicData.nowPlaying.title} added to queue` + ); + msg.guild.musicData.queue.unshift(msg.guild.musicData.nowPlaying); + return; + } +}; \ No newline at end of file diff --git a/commands/voice/pause.js b/commands/voice/pause.js new file mode 100644 index 0000000..2d6630e --- /dev/null +++ b/commands/voice/pause.js @@ -0,0 +1,28 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class PauseVoice extends Command { + constructor(client) { + super(client, { + name: 'pause', + group: 'voice', + memberName: 'pause', + description: 'pauses music if there is any playing', + guildOnly: true + }); + } + run(msg) { + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('join a channel and try again'); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('there isn\'t a song playing right now lol'); + } + + msg.say('song paused :pause_button:'); + + msg.guild.musicData.songDispatcher.pause(); + } +}; \ No newline at end of file diff --git a/commands/voice/play.js b/commands/voice/play.js new file mode 100644 index 0000000..f4e9779 --- /dev/null +++ b/commands/voice/play.js @@ -0,0 +1,286 @@ +const ytdl = require('ytdl-core'); +const { Command } = require('discord.js-commando'); +const { MessageEmbed } = require('discord.js'); +const Youtube = require('simple-youtube-api'); +const { youtubeAPI } = require('../../config.json'); +const youtube = new Youtube('AIzaSyB9xJENORzZt-GmOGx4WsNCPgKSIxhJcds'); // AIzaSyB9xJENORzZt-GmOGx4WsNCPgKSIxhJcds + +module.exports = class PlayVoice extends Command { + constructor(client) { + super(client, { + name: 'play', + aliases: ['p'], + group: 'voice', + memberName: 'play', + description: 'play a youtube video', + guildOnly: true, + clientPermissions: ['SPEAK', 'CONNECT'], + args: [ + { + key: 'query', + prompt: 'what song u wanna hear?', + type: 'string', + validate: function (query) { + return query.length > 0 && query.length < 200; + } + } + ] + }); + } + async run(msg, { + query + }) { + const voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.say('join a channel and try again'); + + if ( + // if the user entered yt playlist url + query.match( + /^(?!.*\?.*\bv=)https:\/\/www\.youtube\.com\/.*\?.*\blist=.*$/ + ) + ) { + const playlist = await youtube.getPlaylist(query).catch(function () { + return msg.say('playlist is either private or it does not exist'); + }); + // remove the 10 if you removed the queue limit conditions below + const videosObj = await playlist.getVideos(10).catch(function () { + return msg.say( + 'there was a problem getting one of the videos in the playlist' + ); + }); + for (let i = 0; i < videosObj.length; i++) { + const video = await videosObj[i].fetch(); + // this can be uncommented if you choose to limit the queue + // if (msg.guild.musicData.queue.length < 10) { + // + msg.guild.musicData.queue.push( + this.constructSongObj(video, voiceChannel) + ); + // } else { + // return msg.say( + // `I can't play the full playlist because there will be more than 10 songs in queue` + // ); + // } + } + if (msg.guild.musicData.isPlaying == false) { + msg.guild.musicData.isPlaying = true; + return this.playSong(msg.guild.musicData.queue, msg); + } else if (msg.guild.musicData.isPlaying == true) { + return msg.say( + `playlist - :musical_note: ${playlist.title} :musical_note: has been added to queue` + ); + } + } + + // This if statement checks if the user entered a youtube url, it can be any kind of youtube url + if (query.match(/^(http(s)?:\/\/)?((w){3}.)?youtu(be|.be)?(\.com)?\/.+/)) { + query = query + .replace(/(>|<)/gi, '') + .split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/); + const id = query[2].split(/[^0-9a-z_\-]/i)[0]; + const video = await youtube.getVideoByID(id).catch(function () { + return msg.say( + 'there was a problem getting the video you provided' + ); + }); + // // can be uncommented if you don't want the bot to play live streams + // if (video.raw.snippet.liveBroadcastContent === 'live') { + // return msg.say("I don't support live streams!"); + // } + // // can be uncommented if you don't want the bot to play videos longer than 1 hour + // if (video.duration.hours !== 0) { + // return msg.say('I cannot play videos longer than 1 hour'); + // } + // // can be uncommented if you want to limit the queue + // if (msg.guild.musicData.queue.length > 10) { + // return msg.say( + // 'There are too many songs in the queue already, skip or wait a bit' + // ); + // } + msg.guild.musicData.queue.push( + this.constructSongObj(video, voiceChannel) + ); + if ( + msg.guild.musicData.isPlaying == false || + typeof msg.guild.musicData.isPlaying == 'undefined' + ) { + msg.guild.musicData.isPlaying = true; + return this.playSong(msg.guild.musicData.queue, msg); + } else if (msg.guild.musicData.isPlaying == true) { + return msg.say(`${video.title} added to queue`); + } + } + + // if user provided a song/video name + const videos = await youtube.searchVideos(query, 5).catch(function () { + return msg.say( + 'there was a problem searching the video you requested :(' + ); + }); + if (videos.length < 5) { + return msg.say( + `i had some trouble finding what you were looking for, please try again or be more specific lol` + ); + } + const vidNameArr = []; + for (let i = 0; i < videos.length; i++) { + vidNameArr.push(`${i + 1}: ${videos[i].title}`); + } + vidNameArr.push('exit'); + const embed = new MessageEmbed() + .setColor(0xF97DAE) + .setTitle('choose a song by msging a number between 1 and 5') + .addField('song #1', vidNameArr[0]) + .addField('song #2', vidNameArr[1]) + .addField('song #3', vidNameArr[2]) + .addField('song #4', vidNameArr[3]) + .addField('song #5', vidNameArr[4]) + .addField('exit selection', 'exit'); + var songEmbed = await msg.channel.send({ + embed + }); + var that = this; + msg.channel + .awaitMessages( + function (msg) { + return (msg.content > 0 && msg.content < 6) || msg.content === 'exit'; + }, { + max: 1, + time: 60000, + errors: ['time'] + } + ) + .then(function (response) { + const videoIndex = parseInt(response.first().content); + if (response.first().content === 'exit') return songEmbed.delete(); + youtube + .getVideoByID(videos[videoIndex - 1].id) + .then(function (video) { + // // can be uncommented if you don't want the bot to play live streams + // if (video.raw.snippet.liveBroadcastContent === 'live') { + // songEmbed.delete(); + // return msg.say("I don't support live streams!"); + // } + + // // can be uncommented if you don't want the bot to play videos longer than 1 hour + // if (video.duration.hours !== 0) { + // songEmbed.delete(); + // return msg.say('I cannot play videos longer than 1 hour'); + // } + + // // can be uncommented if you don't want to limit the queue + // if (msg.guild.musicData.queue.length > 10) { + // songEmbed.delete(); + // return msg.say( + // 'There are too many songs in the queue already, skip or wait a bit' + // ); + // } + msg.guild.musicData.queue.push( + that.constructSongObj(video, voiceChannel) + ); + if (msg.guild.musicData.isPlaying == false) { + msg.guild.musicData.isPlaying = true; + if (songEmbed) { + songEmbed.delete(); + } + that.playSong(msg.guild.musicData.queue, msg); + } else if (msg.guild.musicData.isPlaying == true) { + if (songEmbed) { + songEmbed.delete(); + } + return msg.say(`${video.title} added to queue`); + } + }) + .catch(function () { + if (songEmbed) { + songEmbed.delete(); + } + return msg.say( + 'an error has occured when trying to get the video id from youtube' + ); + }); + }) + .catch(function () { + if (songEmbed) { + songEmbed.delete(); + } + return msg.say( + 'try again and enter a number between 1 and 5 or exit' + ); + }); + } + playSong(queue, msg) { + const classThis = this; // use classThis instead of 'this' because of lexical scope below + queue[0].voiceChannel + .join() + .then(function (connection) { + const dispatcher = connection + .play( + ytdl(queue[0].url, { + quality: 'highestaudio', + highWaterMark: 1024 * 1024 * 10 + }) + ) + .on('start', function () { + msg.guild.musicData.songDispatcher = dispatcher; + dispatcher.setVolume(msg.guild.musicData.volume); + const videoEmbed = new MessageEmbed() + .setThumbnail(queue[0].thumbnail) + .setColor(0xF97DAE) + .addField('now playing:', queue[0].title) + .addField('duration:', queue[0].duration); + if (queue[1]) videoEmbed.addField('next song:', queue[1].title); + msg.say(videoEmbed); + msg.guild.musicData.nowPlaying = queue[0]; + return queue.shift(); + }) + .on('finish', function () { + if (queue.length >= 1) { + return classThis.playSong(queue, msg); + } else { + msg.guild.musicData.isPlaying = false; + msg.guild.musicData.nowPlaying = null; + msg.guild.musicData.songDispatcher = null; + return msg.guild.me.voice.channel.leave(); + } + }) + .on('error', function (e) { + msg.say('can\'t play song'); + console.error(e); + msg.guild.musicData.queue.length = 0; + msg.guild.musicData.isPlaying = false; + msg.guild.musicData.nowPlaying = null; + msg.guild.musicData.songDispatcher = null; + return msg.guild.me.voice.channel.leave(); + }); + }) + .catch(function (e) { + console.error(e); + return msg.guild.me.voice.channel.leave(); + }); + } + constructSongObj(video, voiceChannel) { + let duration = this.formatDuration(video.duration); + if (duration == '00:00') duration = 'live stream'; + return { + url: `https://www.youtube.com/watch?v=${video.raw.id}`, + title: video.title, + duration, + thumbnail: video.thumbnails.high.url, + voiceChannel + }; + } + // prettier-ignore + formatDuration(durationObj) { + const duration = `${durationObj.hours ? (durationObj.hours + ':') : ''}${ + durationObj.minutes ? durationObj.minutes : '00' + }:${ + (durationObj.seconds < 10) + ? ('0' + durationObj.seconds) + : (durationObj.seconds + ? durationObj.seconds + : '00') + }`; + return duration; + } +}; \ No newline at end of file diff --git a/commands/voice/psycho.js b/commands/voice/psycho.js new file mode 100644 index 0000000..35ae025 --- /dev/null +++ b/commands/voice/psycho.js @@ -0,0 +1,31 @@ +const ytdl = require('ytdl-core'); +const { Command } = require('discord.js-commando'); + +module.exports = class PsychoVoice extends Command { + constructor(client) { + super(client, { + name: 'psycho', + group: 'voice', + memberName: 'psycho', + description: 'plays the psycho by mase', + guildOnly: true + }); + } + async run(msg) { + if (msg.member.voice.channel && !msg.guild.voice) { + const connection = await msg.member.voice.channel.join(); + const stream = ytdl('https://www.youtube.com/watch?v=fnd_HSmAODs', { + filter: 'audioonly' + }); + const dispatcher = connection.play(stream); + + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } else if (msg.guild.voice) { + msg.reply('i\'m already playing that lol'); + } else { + msg.reply('you need to join a voice channel first silly'); + } + } +}; \ No newline at end of file diff --git a/commands/voice/queue.js b/commands/voice/queue.js new file mode 100644 index 0000000..9d9d3f3 --- /dev/null +++ b/commands/voice/queue.js @@ -0,0 +1,29 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class QueueVoice extends Command { + constructor(client) { + super(client, { + name: 'queue', + aliases: ['q', 'song-list', 'next-songs'], + group: 'voice', + memberName: 'queue', + description: 'display song queue', + guildOnly: true + }); + } + run(msg) { + if (msg.guild.musicData.queue.length == 0) + return msg.say('there are no songs in the queue lol'); + const titleArray = []; + msg.guild.musicData.queue.map(obj => { + titleArray.push(obj.title); + }); + var queueEmbed = new MessageEmbed() + .setColor(0xF97DAE) + .setTitle('Music Queue'); + for (let i = 0; i < titleArray.length; i++) { + queueEmbed.addField(`${i + 1}:`, `${titleArray[i]}`); + } + return msg.say(queueEmbed); + } +}; \ No newline at end of file diff --git a/commands/voice/remove.js b/commands/voice/remove.js new file mode 100644 index 0000000..848721a --- /dev/null +++ b/commands/voice/remove.js @@ -0,0 +1,38 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class RemoveVoice extends Command { + constructor(client) { + super(client, { + name: 'remove', + aliases: ['rem'], + group: 'voice', + memberName: 'remove', + description: 'removes a song from the queue', + guildOnly: true, + args: [ + { + key: 'songNumber', + prompt: 'what song u want to remove from q?', + type: 'integer' + } + ] + }); + } + run(msg, { songNumber }) { + if (songNumber < 1 && songNumber >= msg.guild.musicData.queue.length) { + return msg.reply('enter a valid song number lol'); + } + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('join a channel and try again lol'); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('no songs playing right now lol'); + } + + msg.guild.musicData.queue.splice(songNumber - 1, 1); + return msg.say(`removed song #${songNumber} from queue`); + } +}; \ No newline at end of file diff --git a/commands/voice/resume.js b/commands/voice/resume.js new file mode 100644 index 0000000..62124e3 --- /dev/null +++ b/commands/voice/resume.js @@ -0,0 +1,28 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class ResumeVoice extends Command { + constructor(client) { + super(client, { + name: 'resumes', + group: 'voice', + memberName: 'resumes', + description: 'resumes music if there is any stopped', + guildOnly: true + }); + } + run(msg) { + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('join a channel and try again'); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('there isn\'t a song playing right now lol'); + } + + msg.say('song resumed :play_pause:'); + + msg.guild.musicData.songDispatcher.resume(); + } +}; \ No newline at end of file diff --git a/commands/voice/shuffle.js b/commands/voice/shuffle.js new file mode 100644 index 0000000..158fa5c --- /dev/null +++ b/commands/voice/shuffle.js @@ -0,0 +1,49 @@ +const { Command } = require('discord.js-commando'); +const { MessageEmbed } = require('discord.js'); + +module.exports = class ShuffleVoice extends Command { + constructor(client) { + super(client, { + name: 'shuffle', + group: 'voice', + memberName: 'shuffle', + description: 'shuffle the queue', + guildOnly: true + }); + } + run(msg) { + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('join channel and try again k'); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('there is no song playing right now'); + } + + if (msg.guild.musicData.queue.length < 1) + return msg.say('There are no songs in queue'); + + shuffleQueue(msg.guild.musicData.queue); + + const titleArray = []; + msg.guild.musicData.queue.map(obj => { + titleArray.push(obj.title); + }); + var queueEmbed = new MessageEmbed() + .setColor(0xF97DAE) + .setTitle('new music q'); + for (let i = 0; i < titleArray.length; i++) { + queueEmbed.addField(`${i + 1}:`, `${titleArray[i]}`); + } + return msg.say(queueEmbed); + } +}; + +function shuffleQueue(queue) { + for (let i = queue.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + [queue[i], queue[j]] = [queue[j], queue[i]]; + } +} \ No newline at end of file diff --git a/commands/voice/skip.js b/commands/voice/skip.js new file mode 100644 index 0000000..c819a67 --- /dev/null +++ b/commands/voice/skip.js @@ -0,0 +1,25 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class SkipVoice extends Command { + constructor(client) { + super(client, { + name: 'skip', + group: 'voice', + memberName: 'skip', + description: 'skip 1 song in the queue', + guildOnly: true + }); + } + run(msg) { + const voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('join a channel and try again'); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('no songs playing right now bruh'); + } + msg.guild.musicData.songDispatcher.end(); + } +}; \ No newline at end of file diff --git a/commands/voice/skipall.js b/commands/voice/skipall.js new file mode 100644 index 0000000..bce9852 --- /dev/null +++ b/commands/voice/skipall.js @@ -0,0 +1,29 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class SkipAllVoice extends Command { + constructor(client) { + super(client, { + name: 'skipall', + group: 'voice', + memberName: 'skipall', + description: 'skip all songs in the queue', + guildOnly: true + }); + } + run(msg) { + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('join a channel and try again'); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('there is no song playing right now'); + } + if (!msg.guild.musicData.queue) + return msg.say('there are no songs in queue now >:)'); + msg.guild.musicData.songDispatcher.end(); + msg.guild.musicData.queue.length = 0; // clear queue + return; + } +}; \ No newline at end of file diff --git a/commands/voice/skipto.js b/commands/voice/skipto.js new file mode 100644 index 0000000..5c41e66 --- /dev/null +++ b/commands/voice/skipto.js @@ -0,0 +1,39 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class SkipToVoice extends Command { + constructor(client) { + super(client, { + name: 'skipto', + group: 'voice', + memberName: 'skipto', + description: 'skip to a certain song in da q >_<', + guildOnly: true, + args: [{ + key: 'songNumber', + prompt: 'what song u want to skip 2 in da q ???', + type: 'integer' + }] + }); + } + run(msg, { songNumber }) { + if (songNumber < 1 && songNumber >= msg.guild.musicData.queue.length) { + return msg.reply('enter a valid song number dumb'); + } + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('join channel and try again for cool'); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('there is no song playing right now dumby'); + } + + if (msg.guild.musicData.queue < 1) + return msg.reply('there are no songs in queue rn'); + + msg.guild.musicData.queue.splice(0, songNumber - 1); + msg.guild.musicData.songDispatcher.end(); + return; + } +}; \ No newline at end of file diff --git a/commands/voice/squeak.js b/commands/voice/squeak.js new file mode 100644 index 0000000..3dbb355 --- /dev/null +++ b/commands/voice/squeak.js @@ -0,0 +1,27 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class SqueakVoice extends Command { + constructor(client) { + super(client, { + name: 'squeak', + group: 'voice', + memberName: 'squeak', + description: 'squeak', + guildOnly: true + }); + } + async run(msg) { + if (msg.member.voice.channel && !msg.guild.voice) { + const connection = await msg.member.voice.channel.join(); + const dispatcher = connection.play('./assets/audio/squeak.wav'); + + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } else if (msg.guild.voice) { + msg.reply('i\'m already playing that lol'); + } else { + msg.reply('you need to join a voice channel first silly'); + } + } +}; \ No newline at end of file diff --git a/commands/voice/uhhhh.js b/commands/voice/uhhhh.js new file mode 100644 index 0000000..0ea364d --- /dev/null +++ b/commands/voice/uhhhh.js @@ -0,0 +1,28 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class MoanVoice extends Command { + constructor(client) { + super(client, { + name: 'moan', + aliases: ['uhhhh'], + group: 'voice', + memberName: 'moan', + description: 'uhhhh', + guildOnly: true + }); + } + async run(msg) { + if (msg.member.voice.channel && !msg.guild.voice) { + const connection = await msg.member.voice.channel.join(); + const dispatcher = connection.play('./assets/audio/uhhhh.wav'); + + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } else if (msg.guild.voice) { + msg.reply('i\'m already playing that lol'); + } else { + msg.reply('you need to join a voice channel first silly'); + } + } +}; \ No newline at end of file diff --git a/commands/voice/volume.js b/commands/voice/volume.js new file mode 100644 index 0000000..e29486d --- /dev/null +++ b/commands/voice/volume.js @@ -0,0 +1,38 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class VolumeVoice extends Command { + constructor(client) { + super(client, { + name: 'volume', + aliases: ['vol', 'v'], + group: 'voice', + memberName: 'volume', + description: 'changes volume of audio if playing', + guildOnly: true, + args: [ + { + key: 'wantedVol', + prompt: 'what volume u want, from 1 to 200', + type: 'integer', + validate: wantedVol => wantedVol >= 1 && wantedVol <= 200 + } + ] + }); + } + run(msg, { wantedVol }) { + var voiceChannel = msg.member.voice.channel; + if (!voiceChannel) return msg.reply('join a channel and try again'); + + if ( + typeof msg.guild.musicData.songDispatcher == 'undefined' || + msg.guild.musicData.songDispatcher == null + ) { + return msg.reply('there isn\'t a song playing right now lol'); + } + + const volume = wantedVol / 100; + msg.guild.musicData.volume = volume; + msg.guild.musicData.songDispatcher.setVolume(volume); + msg.reply(`volume is now: ${wantedVol}%`); + } +}; \ No newline at end of file diff --git a/commands/voice/wahoo.js b/commands/voice/wahoo.js new file mode 100644 index 0000000..d89dfe3 --- /dev/null +++ b/commands/voice/wahoo.js @@ -0,0 +1,28 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class WahooVoice extends Command { + constructor(client) { + super(client, { + name: 'wahoo', + aliases: ['mario'], + group: 'voice', + memberName: 'wahoo', + description: 'wahoo', + guildOnly: true + }); + } + async run(msg) { + if (msg.member.voice.channel && !msg.guild.voice) { + const connection = await msg.member.voice.channel.join(); + const dispatcher = connection.play('./assets/audio/wahoo.mp3'); + + dispatcher.on('finish', () => { + connection.disconnect(); + }); + } else if (msg.guild.voice) { + msg.reply('i\'m already playing that lol'); + } else { + msg.reply('you need to join a voice channel first silly'); + } + } +}; \ No newline at end of file diff --git a/commands/volume.js b/commands/volume.js deleted file mode 100644 index a809c1c..0000000 --- a/commands/volume.js +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = { - name: 'volume', - aliases: ['vol'], - description: '', - async execute(msg, args, bot) { - msg.reply('volume is under works rn, just use the slider lol'); - // if (!args) { - // msg.reply('no volume specified >:('); - // } else { - // var volume = args[0]; - - // dispatcher.setVolume(volume); - // } - } -}; \ No newline at end of file diff --git a/commands/wahoo.js b/commands/wahoo.js deleted file mode 100644 index a6e7c96..0000000 --- a/commands/wahoo.js +++ /dev/null @@ -1,21 +0,0 @@ -const voice_check_dialog = require('../utils/voice_check_dialog.js'); - -module.exports = { - name: 'wahoo', - aliases: ['mario'], - description: '', - async execute(msg, args, bot) { - if (msg.member.voiceChannel && !msg.guild.voiceConnection) { - const connection = await msg.member.voiceChannel.join(); - const dispatcher = connection.playFile('./assets/audio/wahoo.mp3', { - volume: 1.0 - }); - - dispatcher.on('end', () => { - msg.member.voiceChannel.leave(); - }); - } else { - voice_check_dialog.execute(msg); - } - } -}; \ No newline at end of file diff --git a/config.json b/config.json index 42faccc..6dc2c99 100644 --- a/config.json +++ b/config.json @@ -1,13 +1,4 @@ { "secret":"Njk1MTA3NTUwNDAzNzU2MTky.XoVXcQ.JqQAhfqtYW-fz5nYCHvo13BjXAM", - "prefixes": { - "main":"s5n!", - "alt":"s5nical!", - "alt2":"s5n-", - "alt3":"s5nical- ", - "alt4":"s5n.", - "alt5":"s5nical.", - "alt6":"<@!695107550403756192> ", - "alt6b":"<@695107550403756192> " - } + "yt-api-key":"AIzaSyB9xJENORzZt-GmOGx4WsNCPgKSIxhJcds" } \ No newline at end of file diff --git a/docs/help_embed_format.js b/docs/help_embed_format.js deleted file mode 100644 index 42210f8..0000000 --- a/docs/help_embed_format.js +++ /dev/null @@ -1,34 +0,0 @@ -if (command == 'help') { - if (!args.length) { - let emb = new Discord.RichEmbed() - - .setDescription(` - **command list**\nlink not yet set lol\n\n**categories list:**\n\`s5n!help \`\n\n**full list**\n\`y!commands\`\n\n*this doesn't even work, it's just here for future purposes lol* - `) - .setColor(0xF97DAE); - - msg.channel.send(RichEmbed = emb); - } else if (args[0] == 'quotes' || args[0] == 'quote') { - let emb = new Discord.RichEmbed() - - .setTitle('ships -> ship command: (server only)') - .setThumbnail(`${msg.guild.iconURL}`) - .setDescription(`Creates a bond between you and the user you tag. (if they accept)`) - .addField('details', `Creates a bond between you and the user you tag. (if they accept) -@member: Creates a ship with a member if they accept. -sink: Sinks your ship. (unship) -view {@member}: View a ship, leave blank for your own or tag a member. -rename : Renames your ship. -color : Changes the color of your ship.`, false) - .addField(`format`, `\`y!ship [ | sink | view { | rename | color }]\``, true) - .addField('examples', `\`y!ship @member\` - Asks @member if they want to create a ship with you -\`y!ship view @member\` - Views the ship of @member if they have one -\`y!ship rename LoveBoat\` - Renames your ship to 'LoveBoat' -\`y!ship color 0x1E1E1E\` - Changes your ship colour to '0x1E1E1E' -\`y!ship sink\` - Leaves your ship`, false) - .setFooter('<> - required, | - either/or, {} - optional') - .setColor(0xF97DAE); - - msg.channel.send(RichEmbed = emb); - } -} \ No newline at end of file diff --git a/package.json b/package.json index 4910456..da8417c 100644 --- a/package.json +++ b/package.json @@ -12,12 +12,15 @@ "@discordjs/opus": "^0.1.0", "at-quotes": "^1.3.3", "demojijs": "^1.2.0", - "discord.js": "^11.6.3", + "discord.js": "github:discordjs/discord.js", + "discord.js-commando": "github:discordjs/Commando", "emoji-random": "^0.1.2", - "ffmpeg-static": "^4.0.1", + "ffmpeg-static": "^4.1.0", "is-image-url": "^1.1.8", "moment": "^2.24.0", "moment-duration-format": "^2.3.2", + "node-opus": "^0.3.3", + "simple-youtube-api": "^5.2.1", "ytdl-core": "^2.0.1" } } diff --git a/utils/bot_voice_check.js b/utils/bot_voice_check.js deleted file mode 100644 index e68eab9..0000000 --- a/utils/bot_voice_check.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - name: 'bot_voice_check', - description: '', - async execute(msg, args, bot) { - if (msg.guild.voiceConnection) return true; - } -}; \ No newline at end of file diff --git a/utils/no_args.js b/utils/no_args.js deleted file mode 100644 index ff528da..0000000 --- a/utils/no_args.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - name: 'no_args', - description: '', - async execute(msg, args, bot) { - msg.channel.send(`invalid argument(s). type \`${config.prefixes.main}help\` for more information.`); - } -}; \ No newline at end of file diff --git a/utils/no_command.js b/utils/no_command.js deleted file mode 100644 index 04a5768..0000000 --- a/utils/no_command.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - name: 'no_command', - description: '', - async execute(msg, args, bot) { - msg.channel.send(`invalid or unspecified command. type \`${config.prefixes.main}help\`.`); - } -}; \ No newline at end of file diff --git a/utils/perms.js b/utils/perms.js deleted file mode 100644 index 9334d91..0000000 --- a/utils/perms.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - name: 'perms', - description: '', - async execute(msg, args, bot) { - if (msg.member.hasPermission(p)) return true; - } -}; \ No newline at end of file diff --git a/utils/user_voice_check.js b/utils/user_voice_check.js deleted file mode 100644 index effbd2d..0000000 --- a/utils/user_voice_check.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - name: 'user_voice_check', - description: '', - async execute(msg, args, bot) { - if (msg.member.voiceChannel) return true; - } -}; \ No newline at end of file diff --git a/utils/voice_check.js b/utils/voice_check.js new file mode 100644 index 0000000..cae410e --- /dev/null +++ b/utils/voice_check.js @@ -0,0 +1,19 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class VoiceCheckDialog extends Command { + constructor(client) { + super(client, { + name: 'voice_check_dialog', + group: 'utils', + memberName: 'voice_check_dialog', + description: '', + }); + } + run(msg) { + if (msg.guild.voice) { + msg.reply('i\'m already playing that lol'); + } else { + msg.reply('you need to join a voice channel first silly'); + } + } +}; \ No newline at end of file diff --git a/utils/voice_check_dialog.js b/utils/voice_check_dialog.js deleted file mode 100644 index fabf1a8..0000000 --- a/utils/voice_check_dialog.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - name: 'voice_check_dialog', - description: '', - async execute(msg, args, bot) { - if (msg.guild.voiceConnection) { - msg.reply('i\'m already playing that lol'); - } else { - msg.reply('you need to join a voice channel first silly'); - } - } -}; \ No newline at end of file -- cgit v1.2.3