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
|
import { Command } from 'discord-akairo';
import { Message } from 'discord.js';
import { owners, prefix } from '../../Config';
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 async exec(msg: Message, { type }): Promise<Message> {
const existing = this.client.settings.cache.guilds.get(msg.guild.id);
if (!existing) {
this.client.settings.new('guild', {
id: msg.guild.id,
premium: false,
prefix,
});
}
let hasDarling = true;
if (existing.darling === undefined) {
hasDarling = false;
} else {
if (existing.darling.length !== 18) hasDarling = false;
}
if (hasDarling) {
if (type === 'remove') {
if (msg.author.id !== existing.darling) {
if (msg.guild.member(msg.author.id).hasPermission('MANAGE_GUILD') || owners.includes(msg.author.id))
undefined;
else
return msg.reply('Only my darling or someone who has permissions to manage guild settings can remove the current darling!');
}
await this.client.settings.set('guild', { id: msg.guild.id }, { darling: '' });
return msg.reply('The previous darling has been removed!');
} else if (type === 'set') {
return msg.channel.send(`I already have a darling! It's **${msg.guild.members.cache.get(existing.darling).user.tag}**! To set a new darling, either the current darling or someone who has permissions to manage guild settings can do \`${this.client.commandHandler.prefix}darling remove\`.`);
} else if (type === 'check') {
return msg.channel.send(`My darling **${msg.guild.members.cache.get(existing.darling).user.tag}**!`);
}
} else if (!hasDarling) {
if (type === 'remove') {
return msg.reply('There is no darling set in this server!');
} else if (type === 'set') {
await this.client.settings.set('guild', { id: msg.guild.id }, { darling: msg.author.id });
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\`!`);
}
}
undefined;
}
}
|