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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
import { Command, CommandoMessage, CommandoClient } from 'discord.js-commando';
//@ts-ignore
import emoji from 'emoji-random';
import { MessageEmbed } from 'discord.js';
import FanArt from '../../models/FanArt';
import mongo from 'mongoose';
import config from '../../config.json';
mongo.connect(config['mongodburi'], { useNewUrlParser: true, useUnifiedTopology: true })
module.exports = class ArtEmma extends Command {
constructor(client: CommandoClient) {
super(client, {
name: 'art',
aliases: ['artwork'],
group: 'emma',
memberName: 'art',
description: 'Allows you to submit artwork to Emma\'s artwork channel.',
args: [
{
key: 'type',
prompt: 'What type of interaction would you like to do?',
type: 'string',
default: 'submit'
},
{
key: 'comment',
prompt: 'Would you like to leave a comment?',
type: "string",
default: ''
}
],
examples: [
'uwu!art submit <attached file>',
'uwu!art set',
'uwu!art remove'
],
throttling: {
usages: 5,
duration: 30
},
userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'],
clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY']
});
}
//@ts-ignore not assignable bc async
run(msg: CommandoMessage, { type, comment }: any) {
const fanart = new FanArt({
_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
})
//let fanartServer = this.client.guilds.cache.get('663964105983393793');
//@ts-ignore
if (msg.guild.id.toString() != '663964105983393793') return msg.reply(`You are not submitting from **Kat\'s Korner**! ${emoji.random()}`);
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 => {
msg.delete();
m.react('😍');
m.react('😂');
m.react('😁');
m.react('😳');
m.react('😱');
})
/* let emb = new MessageEmbed()
.setDescription(`Fanart by <@${msg.author.id}>.`)
.setTitle('New fanart submitted!')
.setURL(fanart.url)
.addField('Comment', `ok`, true)
.setFooter('Do you want to submit and image or video? Do uwu!help art')
fanartServer?.channels.cache.get('704032357640044556')?.send(emb); */
} else
return msg.reply(`No attachment was submitted! If you need help, please do \`uwu!art help\`. ${emoji.random()}`);
}
);
} else {
return msg.reply(`No attachment was submitted! If you need help, please do \`uwu!art help\`. ${emoji.random()}`);
}
})
} if (type == 'help') {
// msg.guild.channels.cache.get("fanart")?.fetch().then(bool => console.log('get' + bool))
// msg.guild.channels.cache.find(c => c.name == 'fanart')?.fetch().then(bool => console.log(bool + 'ok'))
/* msg.guild.channels.cache.find(c => c.name === 'fanart', (bool) => {
if (!bool) {
console.log('ok')
msg.guild.channels.create('fanart', {
type: 'text',
reason: 'Initialize fanart channel. This is an automated action by the Uwufier bot.',
nsfw: false
})
console.log('made channel')
} else {
console.log('exists')
}
}) */
let emb = new MessageEmbed()
.setTitle('Fanart - Help ' + emoji.random())
.setColor(0xFFCC4D)
.setDescription(`How to submit fanart:`)
//@ts-ignore
.setThumbnail(msg.guild.iconURL())
.addFields([
{
name: '#1',
value: 'Go to the `#media` channel.'
},
{
name: '#2',
value: 'Click on the add media button in the bottom left corner of your screen and select a video or image.'
},
{
name: '#3',
value: 'In the message section, please put `uwu!art submit`.'
},
{
name: '#4 (Optional)',
value: '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!` ' + emoji.random()
},
{
name: 'Admin Stuff',
value: '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 `uwu!art set`, this will set the current channel as the fanart channel. To remove a fanart channel, just do `uwu!art remove`.'
},
{
name: 'More Admin Info',
value: '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.say(emb);
} else if (type == 'set') {
if (!msg.member.hasPermission('MANAGE_GUILD')) return msg.reply(`Insufficient permission! ${emoji.random()}`);
FanArt.findOne({ guildID: msg.guild.id }, async (error, guild) => {
if (error) return console.log(error);
if (guild) {
//@ts-ignore this exists
return msg.reply(`There already is a welcome channel set! It's ${guild.channelname}! ` + emoji.random()).then(mnotif => {
//@ts-ignore this exists
mnotif.delete({ timeout: 2000 })
//@ts-ignore this exists
msg.delete({ timeout: 2000 })
})
} else if (!guild) {
await fanart.save()
.then(result => console.log(result))
.catch(err => console.log(err))
return msg.reply(`The welcome channel has been set to ${msg.channel}! ${emoji.random()}`).then(mnotif => {
//@ts-ignore this exists
mnotif.delete({ timeout: 2000 })
//@ts-ignore this exists
msg.delete({ timeout: 2000 })
})
}
})
} else if (type == 'remove') {
if (!msg.member.hasPermission('MANAGE_GUILD')) return msg.reply(`Insufficient permission! ${emoji.random()}`);
FanArt.findOne({ guildID: msg.guild.id }, async (error, guild) => {
if (error) return console.log(error);
if (guild) {
await FanArt.findOneAndDelete({ guildID: msg.guild.id });
return msg.say(`The current fanart channel has been unset! ${emoji.random()}`).then(mnotif => {
//@ts-ignore
mnotif.delete({ timeout: 2000 });
//@ts-ignore
msg.delete({ timeout: 2000 });
})
} else if (!guild) {
return msg.reply(`There is no current fanart channel set for this guild! ${emoji.random()}`).then(m => {
//@ts-ignore
m.delete({ timeout: 2000 })
//@ts-ignore
msg.delete({ timeout: 2000 })
})
}
})
} else if (type == 'admin-test') {
return msg.reply('**ADMIN INFO:** Art channel bound.')
}
/* else {
return msg.reply(`That is not a valid operation! ${emoji.random()}`);
} */
}
};
|