diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/bot.ts | 14 | ||||
| -rw-r--r-- | src/commands/anime/uwufy.ts | 6 | ||||
| -rw-r--r-- | src/commands/fun/advice.ts | 27 | ||||
| -rw-r--r-- | src/commands/fun/motivate.ts | 2 | ||||
| -rw-r--r-- | src/commands/moderation/ban.ts | 23 | ||||
| -rw-r--r-- | src/commands/moderation/kick.ts | 15 | ||||
| -rw-r--r-- | src/commands/nsfw/danbooru.ts | 69 | ||||
| -rw-r--r-- | src/commands/nsfw/gelbooru.ts | 69 | ||||
| -rw-r--r-- | src/commands/nsfw/rule34.ts | 58 | ||||
| -rw-r--r-- | src/commands/server/goodbye.ts | 88 | ||||
| -rw-r--r-- | src/commands/user/pfp.ts | 9 | ||||
| -rw-r--r-- | src/config.json | 2 | ||||
| -rw-r--r-- | src/models/goodbye.ts | 13 |
13 files changed, 378 insertions, 17 deletions
@@ -2,6 +2,7 @@ import config from './config.json'; import { CommandoClient } from 'discord.js-commando'; //import WS from './ws/ws'; import Welcome from './models/welcome.js'; +import Goodbye from './models/goodbye.js'; import mongo from 'mongoose'; mongo.connect('mongodb://sin:[email protected]:47107/heroku_4qrjvmb9', { useNewUrlParser: true, useUnifiedTopology: true }) import path from 'path'; @@ -85,6 +86,19 @@ client.on('guildMemberAdd', member => { } }) }) +client.on('guildMemberRemove', member => { + Welcome.findOne({ guildID: member.guild.id }, async (error, guild) => { + if (error) { + console.log(error) + } else if (!guild) { + return + } else if (guild) { + member.guild.channels.cache.get(guild.channelID)?.send(`<@${member.id}> has joined **${member.guild.name}**! ` + emoji.random()) + } else { + return + } + }) +}) client.on('message', async msg => { var msgContent = msg.content.toLowerCase(); diff --git a/src/commands/anime/uwufy.ts b/src/commands/anime/uwufy.ts index a2380e5..e3f5f8a 100644 --- a/src/commands/anime/uwufy.ts +++ b/src/commands/anime/uwufy.ts @@ -1,5 +1,6 @@ import { Command, CommandoMessage } from 'discord.js-commando'; import emoji from 'emoji-random'; +import uwufy from 'uwufy' module.exports = class UwufyFun extends Command { constructor(client) { @@ -31,10 +32,7 @@ module.exports = class UwufyFun extends Command { }); } run(msg: CommandoMessage, { userMsg }) { - var m = userMsg; - var u1 = m.replace('r', 'w'); - var u2 = u1.replace('l', 'w'); - msg.reply(u2 + ' ' + emoji.random()); + msg.reply(uwufy(userMsg) + ' ' + emoji.random()) msg.delete(); } };
\ No newline at end of file diff --git a/src/commands/fun/advice.ts b/src/commands/fun/advice.ts new file mode 100644 index 0000000..49e011c --- /dev/null +++ b/src/commands/fun/advice.ts @@ -0,0 +1,27 @@ +import axios from 'axios' +import { Command, CommandoMessage } from 'discord.js-commando'; +import emoji from 'emoji-random'; + +module.exports = class AdviceFun extends Command { + constructor(client) { + super(client, { + name: 'advice', + group: 'fun', + memberName: 'advice', + description: 'Gives you a random piece of advice.', + throttling: { + usages: 5, + duration: 30 + }, + examples: [ + 'uwu!advice' + ], + userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'], + clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'] + }); + } + async run(msg: CommandoMessage) { + let res = await axios.get('http://api.adviceslip.com/advice') + msg.reply(res.data.slip.advice + ' ' + emoji.random()) + } +};
\ No newline at end of file diff --git a/src/commands/fun/motivate.ts b/src/commands/fun/motivate.ts index a0e53e9..3dcd7f6 100644 --- a/src/commands/fun/motivate.ts +++ b/src/commands/fun/motivate.ts @@ -6,7 +6,7 @@ module.exports = class MotivateFun extends Command { constructor(client) { super(client, { name: 'motivate', - aliases: ['motivateme'], + aliases: ['motivateme', 'motivation'], group: 'fun', memberName: 'motivate', description: 'Gives you a random motivating quote from Star Wars.', diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index 5e9be5e..b33a344 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -1,4 +1,5 @@ import { Command, CommandoMessage } from 'discord.js-commando'; +import emoji from 'emoji-random' module.exports = class BanModeration extends Command { constructor(client) { @@ -10,21 +11,31 @@ module.exports = class BanModeration extends Command { description: 'Ban someone.', userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY', 'BAN_MEMBERS'], clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY', 'BAN_MEMBERS'], - examples: ['uwu!ban @sin#1337'], - guildOnly: true, + examples: [ + 'uwu!ban @sin#1337', + 'uwu!banuser @sin#1337', + 'uwu!ban-user @sin#1337' + ], throttling: { usages: 5, duration: 30 }, + guildOnly: true }); } run(msg: CommandoMessage) { - let userID = msg.mentions.members?.first().id - if (!msg.guild.member(userID)) { + let userID = msg.mentions.members?.first() + if (!userID?.id) { + msg.reply('No member was mentioned. ' + emoji.random()) + } else if (userID?.id == msg.author.id) { + msg.reply('You cannot ban yourself.' + emoji.random()) + } else if (userID?.id == this.client.user?.id) { + msg.reply('Not funny. ' + emoji.random()) + } else if (!msg.guild.member(userID.id)) { msg.reply('Member does not exist in server.') } else { - msg.guild.members.ban(userID) - msg.say(`User **${userID}** has been banned!`).then(m => { + msg.guild.members.ban(userID.id) + msg.say(`**${userID}** has been banned!`).then(m => { m.react('🇫'); }) } diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts index 5f6a789..37d08e9 100644 --- a/src/commands/moderation/kick.ts +++ b/src/commands/moderation/kick.ts @@ -1,4 +1,5 @@ import { Command, CommandoMessage } from 'discord.js-commando'; +import emoji from 'emoji-random' module.exports = class KickModeration extends Command { constructor(client) { @@ -23,12 +24,18 @@ module.exports = class KickModeration extends Command { }); } run(msg: CommandoMessage) { - let userID = msg.mentions.members?.first().id - if (!msg.guild.member(userID)) { + let userID = msg.mentions.members?.first() + if (!userID?.id) { + msg.reply('No member was mentioned. ' + emoji.random()) + } else if (userID?.id == msg.author.id) { + msg.reply('You cannot kick yourself.' + emoji.random()) + } else if (userID?.id == this.client.user?.id) { + msg.reply('Not funny. ' + emoji.random()) + } else if (!msg.guild.member(userID.id)) { msg.reply('Member does not exist in server.') } else { - msg.guild.members.prune(userID) - msg.say(`User **${userID}** has been kicked!`).then(m => { + msg.guild.members.prune(userID.id) + msg.say(`**${userID}** has been kicked!`).then(m => { m.react('🇫'); }) } diff --git a/src/commands/nsfw/danbooru.ts b/src/commands/nsfw/danbooru.ts new file mode 100644 index 0000000..87df99e --- /dev/null +++ b/src/commands/nsfw/danbooru.ts @@ -0,0 +1,69 @@ +import { Command, CommandoMessage } from 'discord.js-commando'; +import { MessageEmbed } from 'discord.js'; +import axios from 'axios' + +export default class DanbooruBot extends Command { + constructor(client) { + super(client, { + name: 'danbooru', + group: 'nsfw', + memberName: 'danbooru', + description: 'Danbooru.', + throttling: { + usages: 5, + duration: 30 + }, + examples: [ + 'uwu!danbooru', + 'uwu!danbooru minecraft' + ], + userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'], + clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'], + args: [ + { + key: 'tags', + prompt: 'What tag(s) would you like?', + type: 'string' + } + ], + nsfw: true + }); + } + async run(msg: CommandoMessage, { tags }) { + let randomInt = Math.floor(Math.random() * 100) + let blacklist = ['loli', 'shota', 'cub', 'young', 'child', 'baby', 'guro', 'gore', 'vore', 'scat']; + + if (tags !== 0) { + if (blacklist.includes(tags)) { + msg.reply('Blacklisted word was used! ⛔') + } + } + + let res = await axios.get(`https://danbooru.donmai.us/posts.json?limit=200&tags=${tags}+-rating:safe`) + + if (blacklist.includes(res.data[randomInt].tags)) { + msg.reply('Sorry! This image had a tag that was blacklisted! ⛔') + } + + let getRating = (rating) => { + if (rating === 's') { + return 'Safe' + } if (rating === 'q') { + return 'Questionable' + } if (rating === 'e') { + return 'Explicit' + } if (rating === 'u') { + return 'Unrated' + } + } + + let emb = new MessageEmbed() + .setColor(0xFFCC4D) + .setTitle(`Danbooru - ${!tags ? 'Random Image' : tags}`) + .setDescription(`[Source](http://danbooru.donmai.us/posts/${res.data[randomInt].id})`) + .setImage(res.data[randomInt].file_url) + .setTimestamp(new Date()) + .setFooter(`Score: ${res.data[randomInt].score} | Rating: ${getRating(res.data[randomInt].rating)}`, msg.author.avatarURL()) + msg.say(emb); + } +}
\ No newline at end of file diff --git a/src/commands/nsfw/gelbooru.ts b/src/commands/nsfw/gelbooru.ts new file mode 100644 index 0000000..2f6fdeb --- /dev/null +++ b/src/commands/nsfw/gelbooru.ts @@ -0,0 +1,69 @@ +import { Command, CommandoMessage } from 'discord.js-commando'; +import { MessageEmbed } from 'discord.js'; +import axios from 'axios' + +export default class GelbooruBot extends Command { + constructor(client) { + super(client, { + name: 'gelbooru', + group: 'nsfw', + memberName: 'gelbooru', + description: 'Gelbooru.', + throttling: { + usages: 5, + duration: 30 + }, + examples: [ + 'uwu!gelbooru', + 'uwu!gelbooru minecraft' + ], + userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'], + clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'], + args: [ + { + key: 'tags', + prompt: 'What tag(s) would you like?', + type: 'string' + } + ], + nsfw: true + }); + } + async run(msg: CommandoMessage, { tags }) { + let randomInt = Math.floor(Math.random() * 100) + let blacklist = ['loli', 'shota', 'cub', 'young', 'child', 'baby', 'guro', 'gore', 'vore', 'scat']; + + if (tags !== 0) { + if (blacklist.includes(tags)) { + msg.reply('Blacklisted word was used! â›”') + } + } + + let res = await axios.get(`https://gelbooru.com/index.php?page=dapi&s=post&q=index&limit=100&tags=${tags}+-rating:safe&json=1`) + + if (blacklist.includes(res.data[randomInt].tags)) { + msg.reply('Sorry! This image had a tag that was blacklisted! â›”') + } + + let getRating = (rating) => { + if (rating === 's') { + return 'Safe' + } if (rating === 'q') { + return 'Questionable' + } if (rating === 'e') { + return 'Explicit' + } if (rating === 'u') { + return 'Unrated' + } + } + + let emb = new MessageEmbed() + .setColor(0xFFCC4D) + .setTitle(`Gelbooru - ${!tags ? 'Random Image' : tags}`) + .setDescription(`[Source](https://gelbooru.com/index.php?page=post&s=view&id=${res.data[randomInt].id})`) + .setImage(res.data[randomInt].file_url) + .setTimestamp(new Date()) + .setFooter(`Score: ${res.data[randomInt].score} | Rating: ${getRating(res.data[randomInt].rating)}`, msg.author.avatarURL()) + msg.say(emb); + } +}
\ No newline at end of file diff --git a/src/commands/nsfw/rule34.ts b/src/commands/nsfw/rule34.ts new file mode 100644 index 0000000..eb6fa10 --- /dev/null +++ b/src/commands/nsfw/rule34.ts @@ -0,0 +1,58 @@ +import { Command, CommandoMessage } from 'discord.js-commando'; +import { MessageEmbed } from 'discord.js'; +import axios from 'axios' + +export default class Rule34Bot extends Command { + constructor(client) { + super(client, { + name: 'rule34', + aliases: ['r34'], + group: 'nsfw', + memberName: 'rule34', + description: 'Rule34.', + throttling: { + usages: 5, + duration: 30 + }, + examples: [ + 'uwu!rule34', + 'uwu!rule34 minecraft' + ], + userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'], + clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'], + args: [ + { + key: 'tags', + prompt: 'What tag(s) would you like?', + type: 'string' + } + ], + nsfw: true + }); + } + async run(msg: CommandoMessage, { tags }) { + let randomInt = Math.floor(Math.random() * 100) + let blacklist = ['loli', 'shota', 'cub', 'young', 'child', 'baby', 'guro', 'gore', 'vore', 'scat']; + + if (tags !== 0) { + if (blacklist.includes(tags)) { + msg.reply('Blacklisted word was used! â›”') + } + } + + let res = await axios.get(`http://rule34.xxx/index.php?page=dapi&s=post&q=index&limit=100&tags=${tags}+-rating:safe&json=1`) + + if (blacklist.includes(res.data[randomInt].tags)) { + msg.reply('Sorry! This image had a tag that was blacklisted! â›”') + } + + let emb = new MessageEmbed() + .setColor(0xFFCC4D) + .setTitle(`Rule34 - ${!tags ? 'Random Image' : tags}`) + .setDescription(`[Source](https://rule34.xxx/index.php?page=post&s=view&id=${res.data[randomInt].id})`) + .setImage(`https://rule34.xxx/images/${res.data[randomInt].directory}/${res.data[randomInt].image}`) + .setTimestamp(new Date()) + .setFooter(`Score: ${res.data[randomInt].score} | Rating: ${res.data[randomInt].rating}`, msg.author.avatarURL()) + msg.say(emb); + } +}
\ No newline at end of file diff --git a/src/commands/server/goodbye.ts b/src/commands/server/goodbye.ts new file mode 100644 index 0000000..2300fe2 --- /dev/null +++ b/src/commands/server/goodbye.ts @@ -0,0 +1,88 @@ +import { Command, CommandoMessage } from 'discord.js-commando'; +import emoji from 'emoji-random'; +import Goodbye from '../../models/goodbye.js'; +import mongo from 'mongoose'; +mongo.connect('mongodb://sin:[email protected]:47107/heroku_4qrjvmb9', { useNewUrlParser: true, useUnifiedTopology: true }) + +module.exports = class GoodbyeServer extends Command { + constructor(client) { + super(client, { + name: 'goodbye', + group: 'server', + memberName: 'goodbye', + description: 'Allows you to set, change or delete a server goodbye message.', + userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'], + clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'], + examples: [ + 'uwu!goodbye', + 'uwu!goodbye set', + 'uwu!goodbye remove' + ], + args: [ + { + key: 'wType', + prompt: 'Would you like to set, remove or change the current goodbye channel?', + type: 'string', + default: '' + } + ], + throttling: { + usages: 5, + duration: 30 + }, + guildOnly: true + }); + } + async run(msg: CommandoMessage, { wType }) { + const goodbye = new Goodbye({ + _id: mongo.Types.ObjectId(), + username: msg.author.username, + userID: msg.author.id, + guildname: msg.guild.name, + guildID: msg.guild.id, + channelname: msg.channel, + channelID: msg.channel.id, + time: msg.createdAt + }) + const guildExist = await Goodbye.findOne({ guildID: msg.guild.id }) + + if (msg.member.hasPermission('MANAGE_GUILD')) { + Goodbye.findOne({ guildID: msg.guild.id }, async (error, guild) => { + if (error) { + console.log(error) + } else if (guild && wType == 'remove') { + await Goodbye.findOneAndDelete({ guildID: msg.guild.id }) + msg.say('The current goodbye channel has been unset! ' + emoji.random()).then(mnotif => { + mnotif.delete({ timeout: 2000 }) + msg.delete({ timeout: 2000 }) + }) + } else if (!guild && wType == 'remove') { + msg.reply('There is no current goodbye channel set for this guild! ' + emoji.random()).then(mnotif => { + mnotif.delete({ timeout: 2000 }) + msg.delete({ timeout: 2000 }) + }) + } else if (guild && wType == 'set') { + msg.reply(`There already is a goodbye channel set! It's ${guild.channelname}! ` + emoji.random()).then(mnotif => { + mnotif.delete({ timeout: 2000 }) + msg.delete({ timeout: 2000 }) + }) + } else if (!guild && wType == 'set') { + await goodbye.save() + .then(result => console.log(result)) + .catch(err => console.log(err)) + + msg.reply(`The goodbye channel has been set to ${msg.channel}! ` + emoji.random()).then(mnotif => { + mnotif.delete({ timeout: 2000 }) + msg.delete({ timeout: 2000 }) + }) + } else if (!guild) { + msg.reply('There is no current goodbye channel set for this guild! To set one, do `uwu!goodbye set` in the channel you want to set it in. ' + emoji.random()) + } else if (guild) { + msg.reply(`The current goodbye channel is ${guild.channelname}. ` + emoji.random()) + } + }) + } else { + msg.reply('Insufficent permissions! ' + emoji.random()) + } + } +};
\ No newline at end of file diff --git a/src/commands/user/pfp.ts b/src/commands/user/pfp.ts index f6948b3..6efba76 100644 --- a/src/commands/user/pfp.ts +++ b/src/commands/user/pfp.ts @@ -6,7 +6,14 @@ module.exports = class PFPServer extends Command { constructor(client) { super(client, { name: 'pfp', - aliases: ['profilepicture', 'profile-picture', 'profileimage', 'profile-image'], + aliases: [ + 'profilepicture', + 'profile-picture', + 'profileimage', + 'profile-image', + 'avatar', + 'avi' + ], group: 'server', memberName: 'pfp', description: 'Grabs the profile picture of a given user.', diff --git a/src/config.json b/src/config.json index c2a7f39..07f687f 100644 --- a/src/config.json +++ b/src/config.json @@ -1,5 +1,5 @@ { "secret":"Njk5NDczMjYzOTk4MjcxNDg5.XpU5oQ.btZuxVudhNllSQY6CxrXXtMJm9A", "yt-api-key":"AIzaSyCeG1lQAeInv4vjFv_eTL9IFAFNdQC9Nk8", - "version":"8.1.2" + "version":"8.2.0" }
\ No newline at end of file diff --git a/src/models/goodbye.ts b/src/models/goodbye.ts new file mode 100644 index 0000000..c650ef9 --- /dev/null +++ b/src/models/goodbye.ts @@ -0,0 +1,13 @@ +import mongo from 'mongoose'; +const goodbyeSchema = new mongo.Schema({ + _id: mongo.Schema.Types.ObjectId, + username: String, + userID: String, + guildname: String, + guildID: String, + channelname: String, + channelID: String, + time: String +}); + +export = mongo.model('Goodbye', goodbyeSchema)
\ No newline at end of file |