summaryrefslogtreecommitdiff
path: root/app.js
diff options
context:
space:
mode:
author8cy <[email protected]>2020-04-03 02:37:42 -0700
committer8cy <[email protected]>2020-04-03 02:37:42 -0700
commit60867fb030bae582082340ead7dbc7efdc2f5398 (patch)
tree4c6a7356351be2e4914e15c4703172597c45656e /app.js
parentcommenting (diff)
downloads5nical-60867fb030bae582082340ead7dbc7efdc2f5398.tar.xz
s5nical-60867fb030bae582082340ead7dbc7efdc2f5398.zip
2020/04/03, 02:34, v1.2.0
Diffstat (limited to 'app.js')
-rw-r--r--app.js426
1 files changed, 386 insertions, 40 deletions
diff --git a/app.js b/app.js
index f27cd3f..97939b7 100644
--- a/app.js
+++ b/app.js
@@ -2,15 +2,17 @@ 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');
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~ owo.', { // Set status
+ bot.user.setActivity('psycho~ uwu', { // Set status
type: 'LISTENING'
});
// Outputs available commands in output console
- commands = ['ping', '8ball/ ball', 'say', 'server'];
+ commands = ['bot', 'help'];
console.log(commands);
});
@@ -18,28 +20,29 @@ bot.on('ready', () => {
bot.on('error', console.error);
// Start Bot Commands
-bot.on('message', msg => {
- console.log(msg.content.toLowerCase());
+bot.on('message', async msg => {
+ //console.log(msg.content.toLowerCase());
if (msg.channel.name === 'bots' || msg.channel.name === 'mods-chat' || msg.member.hasPermission('KICK_MEMBERS')) {
-
var msgContent = msg.content.toLowerCase();
- console.log(msgContent);
- console.log(config.prefixes.main);
+ 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.alt4b)) {
- return "alt4b";
+ 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.alt4b)) {
+ return "alt4b";
}
}
@@ -76,28 +79,28 @@ bot.on('message', msg => {
}
// Returns ping of bot
- if (command == 'ping') {
+ if (command == 'ping' || command == 'ms') {
const t = Date.now();
- msg.channel.send('Please Wait...').then(m => {
+ 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\`.`)
+ .setDescription(`pong! s5nical's is \`${n - t}ms\`. heartbeat \`${bot.ping}ms\`.`)
.setColor(0xF97DAE);
msg.channel.send(RichEmbed = emb);
});
}
- function noargs() {
- msg.channel.send(`Invalid argument(s)! Type \`${config.prefixes.main}help\` for more information.`);
+ function noArgs() {
+ msg.channel.send(`invalid argument(s). type \`${config.prefixes.main}help\` for more information.`);
}
- function nocmd() {
- msg.channel.send(`Invalid or unspecified command! Type \`${config.prefixes.main}help\``);
+ function noCommand() {
+ msg.channel.send(`invalid or unspecified command. type \`${config.prefixes.main}help\`.`);
}
function perms(p) {
@@ -105,14 +108,14 @@ bot.on('message', msg => {
}
// 8ball feature
- if (command == '8ball' || command == 'ball') {
- r = ['Yes~ owo', 'No.', 'Yes!', 'No!', 'What, no.', 'Yes.', 'Maybe.', 'Perhaps.', 'Try again.', 'I\'m not sure.'];
+ if (command == '8ball' || command == 'ball' || command == '8b') {
+ 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')
+ .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);
@@ -128,35 +131,378 @@ bot.on('message', msg => {
}
// Server info feature
- if (command == 'server') {
+ if (command == 'server' || command == 'serverinfo') {
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}\``)
+ .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}`)
+ .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);
}
+
+ 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 == 'pause') {
+ dispatcher.pause();
+ }
+
+ if (command == 'resume' || 'play') {
+ dispatcher.resume();
+ }
+
+ if (command == 'volume' || 'vol') {
+
+ }*/
+
+ // Play mario on a bike
+ if (command == 'abee' || command == 'a-bee') {
+ if (msg.member.voiceChannel && !msg.guild.voiceConnection) {
+ const connection = await msg.member.voiceChannel.join();
+ const dispatcher = connection.playFile('./assets/audio/mario_on_a_bike.mp3', {
+ volume: 0.5
+ });
+
+ dispatcher.on('end', () => {
+ msg.member.voiceChannel.leave();
+ })
+ } else if (msg.guild.voiceConnection) {
+ msg.reply('i\'m already playing that lol')
+ } else {
+ msg.reply('you need to join a voice channel first silly');
+ }
+ }
+
+ // Play squeak on a bike
+ if (command == 'squeak') {
+ 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 if (msg.guild.voiceConnection) {
+ msg.reply('i\'m already playing that lol')
+ } else {
+ msg.reply('you need to join a voice channel first silly');
+ }
+ }
+
+ // Play uhhhh
+ if (command == 'uhhhh') {
+ 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 if (msg.guild.voiceConnection) {
+ msg.reply('i\'m already playing that lol')
+ } else {
+ msg.reply('you need to join a voice channel first silly');
+ }
+ }
+
+ // Plays Mase - Psycho
+ if (command == 'psycho') {
+ if (msg.member.voiceChannel && !msg.guild.voiceConnection) {
+ const connection = await msg.member.voiceChannel.join();
+ const dispatcher = connection.playFile('./assets/audio/mase_psycho.mp3', {
+ volume: 0.5
+ });
+
+ dispatcher.on('end', () => {
+ msg.member.voiceChannel.leave();
+ })
+ } else if (msg.guild.voiceConnection) {
+ msg.reply('i\'m already playing that lol')
+ } else {
+ msg.reply('you need to join a voice channel first silly');
+ }
+ }
// Help
if (command == 'help') {
+ 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);
+ }
+ }
+
+ // Commands which you get directed to from help
+ if (command == 'commands') {
let emb = new Discord.RichEmbed()
- .setDescription(`The available commands are: **ping**, **8ball/ ball**, **say**, **server** and **help**.`)
+ .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);
+ msg.channel.send(RichEmbed = emb);
+ }
+
+ // Member count
+ if (command == 'membercount' || command == 'memberc' || command == 'mcount' || command == 'mc') {
+ msg.reply(`there are **${msg.guild.memberCount}** members in **${msg.guild.name}**`);
}
+
+ // Spits out random emoji
+ if (command == 'moji' || command == 'emoji') {
+ msg.reply(emoji.random());
+ }
+
+ // Spits out random quotes from Adventure TIme
+ if (command == 'quote' || command == 'quotes') {
+ 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());
+ }
+ }
+
+ // 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 ~uwu').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(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');
+ }
+ }
+
+ /*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(0xF97DAE);
+
+ 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;
})