diff options
| author | 8cy <[email protected]> | 2020-04-10 10:16:53 -0700 |
|---|---|---|
| committer | 8cy <[email protected]> | 2020-04-10 10:16:53 -0700 |
| commit | 4b308538961facb87d73fafeab7fab5927562eff (patch) | |
| tree | 8eaf88c074c379d76e7932e6fc3f32c05adb70ca /commands | |
| parent | rework reboot, work on itemshop, v1.5.2 (diff) | |
| download | s5nical-4b308538961facb87d73fafeab7fab5927562eff.tar.xz s5nical-4b308538961facb87d73fafeab7fab5927562eff.zip | |
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)
Diffstat (limited to 'commands')
52 files changed, 1216 insertions, 656 deletions
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/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 <group>\``) - .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 <commands category>\`\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/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/clear.js b/commands/utility/clear.js index fe8e46f..61f9fbb 100644 --- a/commands/clear.js +++ b/commands/utility/clear.js @@ -1,42 +1,58 @@ -module.exports = { - name: 'clear', - aliases: ['delete', 'del', 'c'], - description: '', - async execute(msg, args, bot) { +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 (!args) { + if (!deleteAmount) { msg.reply('you haven\'t specified an amount of messages which should be deleted.').then(deleteNotificationMessage => { - deleteNotificationMessage.delete(1000); + deleteNotificationMessage.delete({ timeout: 1000 }); }); - } else if (isNaN(args)) { + } else if (isNaN(deleteAmount)) { msg.reply('the amount parameter isn\'t a number.').then(deleteNotificationMessage => { - deleteNotificationMessage.delete(1000); + deleteNotificationMessage.delete({ timeout: 1000 }); }); - } else if (args > 100) { + } else if (deleteAmount > 100) { msg.reply('you can\'t delete more than 100 messages at once.').then(deleteNotificationMessage => { - deleteNotificationMessage.delete(1000); + deleteNotificationMessage.delete({ timeout: 1000 }); }); - } else if (args < 1) { + } else if (deleteAmount < 1) { msg.reply('you have to delete at least 1 message.').then(deleteNotificationMessage => { - deleteNotificationMessage.delete(1000); + 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 = parseInt(args[0]) + 1; + 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.fetchMessages({ + 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(1000); + deleteNotificationMessage.delete({ timeout: 1000 }); }); } } else { 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/server.js b/commands/utility/server.js index c410243..0269eba 100644 --- a/commands/server.js +++ b/commands/utility/server.js @@ -1,17 +1,29 @@ -const Discord = require('discord.js'); +const { Command } = require('discord.js-commando'); +const { MessageEmbed } = 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; +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 - emb = new Discord.RichEmbed() + let embed = new MessageEmbed() - .setAuthor(`${msg.guild.name} - ${msg.guild.id}`, `${msg.guild.iconURL}`, `https://discordapp.com/channels/${msg.guild.id}/${msg.guild.id}`) + .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}`) + .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) @@ -21,6 +33,6 @@ module.exports = { .addField('s5nical joined', `${msg.guild.members.get('695107550403756192').joinedAt}`) .setColor(0xF97DAE); - msg.channel.send(RichEmbed = emb); + 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 |