diff options
| author | 8cy <[email protected]> | 2020-04-10 11:33:49 -0700 |
|---|---|---|
| committer | 8cy <[email protected]> | 2020-04-10 11:33:49 -0700 |
| commit | 8f554981cb00b39fb891f27a84b2fc9c04067faf (patch) | |
| tree | 711674ac59c438f78b58a44c9267bb3b438060b0 | |
| parent | add uptime command, v1.0.1 (diff) | |
| download | chester-8f554981cb00b39fb891f27a84b2fc9c04067faf.tar.xz chester-8f554981cb00b39fb891f27a84b2fc9c04067faf.zip | |
remove a lot, v1.1.0
| -rw-r--r-- | app.js | 298 |
1 files changed, 72 insertions, 226 deletions
@@ -1,10 +1,7 @@ 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).`); @@ -15,240 +12,89 @@ bot.on('ready', () => { bot.on('error', console.error); -// Start Bot Commands bot.on('message', async msg => { - //if (msg.channel.name === 'bots' || msg.channel.name === 'bot-commands' || msg.member.hasPermission('KICK_MEMBERS')) { - const upTime = require('moment'); - require('moment-duration-format'); - const duration = upTime.duration(bot.uptime).format(" D [days], H [hrs], m [mins], s [secs]"); - - var msgContent = msg.content.toLowerCase(); - if (prefixCheck()) { - console.log(msg.member.user.tag, 'says', msgContent, 'in #' + msg.channel.name); - } - - // 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; - } - - // Returns ping of bot - if (command == 'ping' || command == 'ms') { - const t = Date.now(); - - msg.channel.send('plz wait..').then(m => { + const upTime = require('moment'); + require('moment-duration-format'); + const duration = upTime.duration(bot.uptime).format(" D [days], H [hrs], m [mins], s [secs]"); + + function prefixCheck() { + if (msgContent.startsWith('c!')) { + return true; + } + var msgContent = msg.content.toLowerCase(); + if (prefixCheck()) { + console.log(msg.member.user.tag, 'says', msgContent, 'in #' + msg.channel.name); + } + + if (command == 'ping' || command == 'ms') { + const t = Date.now(); + + msg.channel.send('plz wait..').then(m => { m.edit(`** **`); - const n = Date.now(); - let emb = new Discord.RichEmbed() - - .setDescription(`pong! chesters's is \`${n - t}ms\`. heartbeat \`${bot.ping}ms\`.`) - .setColor(0xFFE4BA); - - msg.channel.send(RichEmbed = emb); - }); - } - - function noArgs() { - msg.channel.send(`invalid argument(s). type \`${config.prefixes.main}help\` for more information.`); - } + const n = Date.now(); + let emb = new Discord.RichEmbed() - function noCommand() { - msg.channel.send(`invalid or unspecified command. type \`${config.prefixes.main}help\`.`); - } + .setDescription(`bork! chesters's is \`${n - t}ms\`. heartbeat \`${bot.ping}ms\`.`) + .setColor(0xFFE4BA); - function perms(p) { - if (msg.member.hasPermission(p)) return true; - } - - // Say feature, bot repeats what you say - if (command == 'say') { - if (msg.member.hasPermission('KICK_MEMBERS')) { - m = args.join(' '); - msg.channel.send(m); - msg.delete(); - } - } + msg.channel.send(RichEmbed = emb); + }); + } - if (command == 'leave') { - if (msg.guild.voiceConnection) { - msg.guild.voiceConnection.disconnect(); - msg.reply('succesfully left voice channel'); - } else { - msg.reply('i\'m not in a voice channel'); - } + if (command == 'say') { + if (msg.member.hasPermission('KICK_MEMBERS')) { + m = args.join(' '); + msg.channel.send(m); + msg.delete(); } + } - if (command == 'join') { - 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'); - } + if (command == 'leave') { + if (msg.guild.voiceConnection) { + msg.guild.voiceConnection.disconnect(); + msg.reply('succesfully left voice channel'); + } else { + msg.reply('i\'m not in a voice channel' + emoji.random()); } + } - if (command == 'reboot' | command == 'r') { + if (command == 'join') { + if (!msg.guild.voiceConnection && msg.member.voiceChannel) { msg.member.voiceChannel.join(); - msg.member.voiceChannel.leave(); - msg.reply('reboot finished lol'); - } - - // Clear/ delete messages in bulk command - if (command == 'clear' || command == 'delete' || command == 'del' || command == 'c') { - 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 ~bork').then(deleteNotificationMessage => { - deleteNotificationMessage.delete(1000); - }); - } - } else { - msg.reply('insufficent perms bruh'); - } - } - - if (command == 'dm') { - 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.first()) { - 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[0]); - - let emb = new Discord.RichEmbed() - - //.setDescription(`to view the commands in each group use:\n\`s5n!commands <group>\``) - .addField(`message`, args[1], true) - .addField(`recipient`, args[0], true) - .addField(`time sent`, d) - .setColor(0xFFE4BA); - - msg.channel.send(RichEmbed = emb); - }); - } - } else { - msg.reply('insufficent perms bruh'); - } - } - - if (msg.mentions.everyone) { - msg.react(':ArisaPing:695887537390223402'); - } - - if (msg.content == 'dog' | msg.content == 'dogs' | msg.content == 'bark' | msg.content == 'bork' | msg.content == 'woof') { - var borkNum = Math.floor((Math.random() * 3) + 1); - - if (borkNum == 1) { - msg.reply('bork'); - } else if (borkNum == 2) { - msg.reply('bark'); - } else if (borkNum == 3) { - msg.reply('woof'); - } - } - - if (command == 'owner') { - msg.reply('my owner is papa frozen'); - } - - if (command == 'uptime' || command == 'ut') { - msg.reply(duration); - } - //} else if (msg.channel.name !== 'bots' && msg.content.startsWith(`${config.prefixes.main}`) && !msg.member.hasPermission('KICK_MEMBERS')) return; + msg.reply('succesfully joined voice channel' + emoji.random()); + } else if (msg.guild.voiceConnection) { + msg.reply('i\'m already in voice channel' + emoji.random()); + } else if (!msg.member.voiceChannel) { + msg.reply('you\'re not in a voice channel' + emoji.random()); + } + } + + if (command == 'reboot' | command == 'r') { + msg.member.voiceChannel.join(); + msg.member.voiceChannel.leave(); + msg.reply('reboot finished lol' + emoji.random()); + } + + if (msg.mentions.everyone) { + msg.react(':ArisaPing:695887537390223402'); + } + + if (msg.content == 'dog' | msg.content == 'dogs' | msg.content == 'bark' | msg.content == 'bork' | msg.content == 'woof') { + var borkNum = Math.floor((Math.random() * 3) + 1); + + if (borkNum == 1) { + msg.reply('bork' + emoji.random()); + } else if (borkNum == 2) { + msg.reply('bark' + emoji.random()); + } else if (borkNum == 3) { + msg.reply('woof' + emoji.random()); + } + } + + if (command == 'uptime' || command == 'ut') { + msg.reply(duration + emoji.random()); + } }) // Get bot token |