diff options
| author | 8cy <[email protected]> | 2020-07-23 23:24:17 -0700 |
|---|---|---|
| committer | 8cy <[email protected]> | 2020-07-23 23:24:17 -0700 |
| commit | bb511abc03bb66848947e37a999502b813c77269 (patch) | |
| tree | 612c010fc8317e1cdf11471a18aad0270819d33e /server/src/commands/anime/Darling.ts | |
| parent | fix: if clear amount equal or over 100, round down to 99 (diff) | |
| download | dep-core-bb511abc03bb66848947e37a999502b813c77269.tar.xz dep-core-bb511abc03bb66848947e37a999502b813c77269.zip | |
goodbye old uwufier :cry:
Diffstat (limited to 'server/src/commands/anime/Darling.ts')
| -rw-r--r-- | server/src/commands/anime/Darling.ts | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/server/src/commands/anime/Darling.ts b/server/src/commands/anime/Darling.ts new file mode 100644 index 0000000..5b5a7bb --- /dev/null +++ b/server/src/commands/anime/Darling.ts @@ -0,0 +1,90 @@ +import { Command } from 'discord-akairo'; +import { Message } from 'discord.js'; +import Darling from '../../database/models/DarlingModel'; +import mongoose from 'mongoose'; +import { mongoDBUri } from '../../Config'; +mongoose.connect(mongoDBUri, { + useNewUrlParser: true, + useUnifiedTopology: true +}); + +export default class DarlingAnime extends Command { + public constructor() { + super('darling', { + aliases: ['darling'], + category: 'anime', + description: { + content: 'Allows you to set, check or delete the/ a server\'s darling.', + usage: '[type]', + examples: [ + '', + 'set', + 'remove', + 'check' + ] + }, + ratelimit: 3, + channel: 'guild', + args: [ + { + id: 'type', + type: 'string', + prompt: { + start: 'Would you like to set, check or delete the current darling?', + retries: 3, + retry: 'Sorry, that was not a valid type.' + } + } + ], + userPermissions: ['MANAGE_GUILD'] + }); + } + + public exec(msg: Message, { type }): Promise<Message> | any { + const darling = new Darling({ + _id: mongoose.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 + }); + + return Darling.findOne({ guildID: msg.guild.id }, async (error, guild) => { + if (error) return console.error(error); + + if (guild) { + if (type === 'remove') { + //@ts-ignore + if (msg.author.id !== guild.userID || msg.author.id !== msg.guild.owner.id) + return msg.reply('Only my darling or the guild owner can remove the current darling.'); + + await Darling.findOneAndDelete({ guildID: msg.guild.id }); + return msg.channel.send('The current darling has been removed!'); + } else if (type === 'set') { + //@ts-ignore + return msg.channel.send(`I already have a darling! It's **${guild.username}**! To set a new darling, either the current darling or the guild owner has to do \`${this.client.commandHandler.prefix}darling remove\`.`); + } else if (type === 'check') { + //@ts-ignore + return msg.channel.send(`My darling is ${guild.username}.`); + } + } else if (!guild) { + if (type === 'remove') { + return msg.channel.send('There is no darling set in this server.'); + } else if (type === 'set') { + await darling.save().catch(err => console.error(err)); + const quotes = [ + 'I think I have taken a liking to you. Won\'t you be my darling?', + 'I like the look in your eyes. It makes my heart race. You are now my darling!', + 'Wow, your taste makes my heart race. It bites and lingers... The taste of danger. You are now my darling!' + ]; + return msg.channel.send(quotes[Math.floor(Math.random() * quotes.length)]); + } else if (type === 'check') { + return msg.reply(`I haven't found my darling yet! To set one, do ${this.client.commandHandler.prefix}darling set.`); + } + } + }); + } +}
\ No newline at end of file |