summaryrefslogtreecommitdiff
path: root/server/src/commands/emma/FanArt.ts
diff options
context:
space:
mode:
author8cy <[email protected]>2020-07-23 23:24:17 -0700
committer8cy <[email protected]>2020-07-23 23:24:17 -0700
commitbb511abc03bb66848947e37a999502b813c77269 (patch)
tree612c010fc8317e1cdf11471a18aad0270819d33e /server/src/commands/emma/FanArt.ts
parentfix: if clear amount equal or over 100, round down to 99 (diff)
downloaddep-core-bb511abc03bb66848947e37a999502b813c77269.tar.xz
dep-core-bb511abc03bb66848947e37a999502b813c77269.zip
goodbye old uwufier :cry:
Diffstat (limited to 'server/src/commands/emma/FanArt.ts')
-rw-r--r--server/src/commands/emma/FanArt.ts132
1 files changed, 132 insertions, 0 deletions
diff --git a/server/src/commands/emma/FanArt.ts b/server/src/commands/emma/FanArt.ts
new file mode 100644
index 0000000..3cab365
--- /dev/null
+++ b/server/src/commands/emma/FanArt.ts
@@ -0,0 +1,132 @@
+import { Command } from 'discord-akairo';
+import { Message } from 'discord.js';
+import FanArt from '../../database/models/FanArtModel';
+import mongoose from 'mongoose';
+import { mongoDBUri, colour } from '../../Config';
+mongoose.connect(mongoDBUri, {
+ useNewUrlParser: true,
+ useUnifiedTopology: true
+});
+
+export default class FanArtEmma extends Command {
+ public constructor() {
+ super('fanart', {
+ aliases: ['fanart', 'art'],
+ category: 'emma',
+ description: {
+ content: 'Allows you to set, check or delete the/ a server fanart channel.',
+ 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 fanart channel?',
+ retries: 3,
+ retry: 'Sorry, that was not a valid type.'
+ }
+ },
+ {
+ id: 'comment',
+ type: 'string'
+ }
+ ],
+ userPermissions: ['MANAGE_GUILD']
+ });
+ }
+
+ public exec(msg: Message, { type, comment }): Promise<Message> | any {
+ if (msg.guild.id.toString() !== '663964105983393793') return;
+ const welcome = new FanArt({
+ _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
+ });
+
+ const validTypes = ['set', 'remove', 'check'];
+
+ if (type === 'submit') {
+ FanArt.findOne({ guildID: msg.guild.id }, async (error, guild) => {
+ if (error) return console.log(error);
+
+ //@ts-ignore
+ let fanartServer = this.client.guilds.cache.get(guild.guildID);
+ //@ts-ignore
+ let fanartChannel = guild.channelID;
+
+ if (msg.attachments.size) {
+ msg.attachments.forEach(fanart => {
+ if (fanart.url) {
+ //@ts-ignore
+ return fanartServer.channels.cache.get(fanartChannel).send(`**New fanart submitted!**\nFanart by <@${msg.author.id}>.\n\n**Comment**\n${comment ? comment : 'None.'}\n\n**Video** ` + fanart.url)
+ .then(m => {
+ m.react('😍');
+ m.react('😂');
+ m.react('😁');
+ m.react('😳');
+ m.react('😱');
+ });
+ } else {
+ return msg.reply(`No attachment was submitted! If you need help, please do \`${this.client.commandHandler.prefix}fanart help\`.`);
+ }
+ });
+ } else {
+ return msg.reply(`No attachment was submitted! If you need help, please do \`${this.client.commandHandler.prefix}fanart help\`.`);
+ }
+ });
+ } else if (type === 'help') {
+ const embed = this.client.util.embed()
+ .setTitle('Fanart - Help')
+ .setColor(colour)
+ .setDescription('How to submmit fanart:')
+ .setThumbnail(msg.guild.iconURL())
+ .addField('#1', 'Go to the `#media` channel.')
+ .addField('#2', 'Click on the add media button in the bottom left corner of your screen and select a video or image.')
+ .addField('#3', 'In the message section, please put `uwu!art submit`.')
+ .addField('#4 (Optional)', 'If you would like, you can also put a comment on your fanart, you can do this by adding an extra string to the end of your submit command. e.g. `uwu!art submit this is where the comment goes!`, if you followed the steps correctly, your comment should be `this is where the comment goes!')
+ .addField('Admin Stuff', `If you are an admin or moderator who would like to set/ remove a fanart channel, you can do this by going to to the channel you would like to set as the new fanart channel and doing \`${this.client.commandHandler.prefix}fanart set\`, this will set the current channel as the fanart channel. To remove a fanart channel, just do \`${this.client.commandHandler.prefix}fanart remove\`.`)
+ .addField('More Admin Info', 'You can only have **ONE** fanart channel (I think, I haven\'t tested it lol. If you change the name of the fanart channel, you will have to re-register with the bot by simply removing and re-setting the fanart channel');
+ return msg.channel.send(embed);
+ } else if (validTypes.includes(type)) {
+ return FanArt.findOne({ guildID: msg.guild.id }, async (error, guild) => {
+ if (error) return console.error(error);
+
+ if (guild) {
+ if (type === 'remove') {
+ await FanArt.findOneAndDelete({ guildID: msg.guild.id });
+ return msg.channel.send('The current fanart channel has been unset!');
+ } else if (type === 'set') {
+ //@ts-ignore
+ return msg.channel.send(`There already is a fanart channel set! It's ${guild.channelname}`);
+ } else if (type === 'check') {
+ //@ts-ignore
+ return msg.channel.send(`The current fanart channel is ${guild.channelname}!`);
+ }
+ } else if (!guild) {
+ if (type === 'remove') {
+ return msg.channel.send('There is no current fanart channel set for this guild!');
+ } else if (type === 'set') {
+ await welcome.save().catch(err => console.error(err));
+ return msg.channel.send(`The fanart channel has been set to ${msg.channel!}`);
+ } else if (type === 'check') {
+ return msg.reply(`There is no current fanart channel set for this guild! To set one, do ${this.client.commandHandler.prefix}fanart set in the channel you want to set it in!`);
+ }
+ }
+ });
+ }
+ }
+} \ No newline at end of file