diff options
| author | 8cy <[email protected]> | 2020-04-07 05:38:58 -0700 |
|---|---|---|
| committer | 8cy <[email protected]> | 2020-04-07 05:38:58 -0700 |
| commit | 03ac01423d0ee384688f770d1a00a12024d4f544 (patch) | |
| tree | d0c94883f05332c5e13300e762a524eab9393810 | |
| download | chester-03ac01423d0ee384688f770d1a00a12024d4f544.tar.xz chester-03ac01423d0ee384688f770d1a00a12024d4f544.zip | |
v1.0.0
| -rw-r--r-- | .gitignore | 6 | ||||
| -rw-r--r-- | Procfile | 1 | ||||
| -rw-r--r-- | app.js | 360 | ||||
| -rw-r--r-- | config.json | 13 | ||||
| -rw-r--r-- | package.json | 21 |
5 files changed, 401 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f3e60f0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +node_modules/ +package-lock.json +.vscode +.vs +.idea +.eclipse diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..ad01c27 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +worker: node app.js @@ -0,0 +1,360 @@ +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('with squeaky toy :D', { // Set status + type: 'PLAYING' + }); + + // 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; + } + + // Returns ping of bot + 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.`); + } + + function noCommand() { + msg.channel.send(`invalid or unspecified command. type \`${config.prefixes.main}help\`.`); + } + + 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(); + } + } + + 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 == '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 == 'reboot' | command == 'r') { + msg.member.voiceChannel.join(); + msg.member.voiceChannel.leave(); + msg.reply('reboot finished lol'); + } + + /*if (command == 'pause') { + dispatcher.pause(); + } + + if (command == 'resume' || 'play') { + dispatcher.resume(); + } + + if (command == 'volume' || 'vol') { + + }*/ + + // 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); + }) + } + + // 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'); + } + } + + 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 == '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'); + } + }*/ + + // Change status and status message + /*if (command == 'botstatus' || command == 'status' || command == 'bs') { + if (msg.member.hasPermission('KICK_MEMBERS')) { + if (!args[0] && !args[1]) { + msg.reply('you haven\'t specified a status or a message.') + } else if (!args[1]) { + msg.reply('you haven\'t specified a message.') + } else if (!args[0]) { + msg.reply('you haven\'t specified a status.') + } else { + status = args[0].toLocaleUpperCase(); + var d = new Date(msg.createdTimestamp); + + bot.user.setActivity(args[1], { + type: status + }); + + let emb = new Discord.RichEmbed() + + //.setDescription(`to view the commands in each group use:\n\`s5n!commands <group>\``) + .addField(`status message`, args[1], true) + .addField(`status`, status, true) + .addField(`time changed`, d) + .setColor(0xFFE4BA); + + msg.channel.send(RichEmbed = emb); + } + } + }*/ + + /*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/config.json b/config.json new file mode 100644 index 0000000..9dd98f9 --- /dev/null +++ b/config.json @@ -0,0 +1,13 @@ +{ + "secret":"Njk3MDUyNjkwNzM5NDk0OTky.Xoxt3g.7Wc4CBv2V2130PLYrIY0Q6sfMyE", + "prefixes": { + "main":"c!", + "alt":"chester!", + "alt2":"c-", + "alt3":"chester- ", + "alt4":"c.", + "alt5":"chester.", + "alt6":"<@!697052690739494992> ", + "alt6b":"<@697052690739494992> " + } +}
\ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..9e0f1e4 --- /dev/null +++ b/package.json @@ -0,0 +1,21 @@ +{ + "name": "package", + "version": "1.0.0", + "description": "", + "main": "app.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "sin", + "license": "MIT", + "dependencies": { + "@discordjs/opus": "^0.1.0", + "at-quotes": "^1.3.3", + "demojijs": "^1.2.0", + "discord.js": "^11.6.3", + "emoji-random": "^0.1.2", + "ffmpeg-static": "^4.0.1", + "is-image-url": "^1.1.8", + "ytdl-core": "^2.0.1" + } +} |