1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
import { Command } from 'discord-akairo';
import { Message } from 'discord.js';
import FanArt from '../../database/models/FanArtModel';
import mongoose from 'mongoose';
import { mongoDBUri, colour, emmaServer } 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() !== emmaServer) 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/ Image** ` + 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!`);
}
}
});
}
}
}
|