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
|
import { Command, CommandoMessage } from 'discord.js-commando';
import emoji from 'emoji-random';
import Darling from '../../models/darling.js';
import mongo from 'mongoose';
mongo.connect('mongodb://sin:[email protected]:47107/heroku_4qrjvmb9', { useNewUrlParser: true, useUnifiedTopology: true })
module.exports = class DarlingZeroTwo extends Command {
constructor(client) {
super(client, {
name: 'darling',
group: 'zerotwo',
memberName: 'darling',
description: 'Allows you to set, change or delete uwufier\'s darling.',
userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'],
clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'],
examples: [
'uwu!darling',
'uwu!darling set',
'uwu!darling remove'
],
args: [
{
key: 'darlingName',
prompt: 'Who should the darling be?',
type: 'string',
default: ''
}
],
throttling: {
usages: 5,
duration: 30
},
guildOnly: true
});
}
async run(msg: CommandoMessage, { darlingName }) {
const darling = new Darling({
_id: mongo.Types.ObjectId(),
username: msg.author.username,
userID: msg.author.id,
guildname: msg.guild.name,
guildID: msg.guild.id,
time: msg.createdAt
})
const guildExist = await Darling.findOne({ guildID: msg.guild.id })
Darling.findOne({ guildID: msg.guild.id }, async (error, guild) => {
if (error) {
console.log(error)
} else if (guild && darlingName == 'remove') {
// @ts-ignore linting error shows that channelID doesnt exist when it does
if (msg.author.id == guild.userID) {
await Darling.findOneAndDelete({ guildID: msg.guild.id })
msg.say('The current darling has been removed. ' + emoji.random())
} else {
msg.reply('Only my darling can remove the current darling. ' + emoji.random())
}
} else if (!guild && darlingName == 'remove') {
msg.reply('There is no darling set in this server. ' + emoji.random())
} else if (guild && darlingName == 'set') {
// @ts-ignore linting error shows that channelID doesnt exist when it does
msg.reply(`I already have a darling! It\'s <@${guild.userID}>! ` + emoji.random())
} else if (!guild && darlingName == 'set') {
await darling.save()
.then(result => console.log(result))
.catch(err => console.log(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!'
]
let quoteNum = quotes[Math.floor(Math.random() * quotes.length)]
msg.reply(quoteNum)
} else if (!guild) {
msg.reply('I haven\'t found my darling yet! To set one, do `uwu!darling set`. ' + emoji.random())
} else if (guild) {
// @ts-ignore linting error shows that channelID doesnt exist when it does
msg.reply(`My darling is <@${guild.userID}>. ` + emoji.random())
}
})
// if (guildExist && darlingName == 'remove') {
// await Darling.findOneAndDelete({ guildID: msg.guild.id })
// msg.say('The current darling has been removed.')
// } else if (!guildExist && darlingName == 'remove') {
// msg.reply('There is no darling set in this server.')
// } else if (darlingName || darlingName == 'set') {
// await darling.save().then(result => console.log(result)).catch(err => console.log(err))
// var quoteNum = Math.floor((Math.random() * 3) + 1);
// switch (quoteNum) {
// case 1: var quoteResult = 'I think I have taken a liking to you. Won\'t you be my darling?'; break
// case 2: var quoteResult = 'I like the look in your eyes. It makes my heart race. You are now my darling!'; break
// case 3: var quoteResult = 'Wow, your taste makes my heart race. It bites and lingers... The taste of danger. You are now my darling!'; break
// default: var quoteResult = 'I think I have taken a liking to you. Won\'t you be my darling?'; break
// }
// msg.reply(quoteResult)
// } else if (!guildExist) {
// msg.reply('I haven\'t found my darling yet!')
// } else if (guildExist) {
// await Darling.findOne({ userID: msg.author.id }, (err) => {
// if (err) console.log(err)
// }).then(res => {
// msg.reply(`My darling is <@${res.userID}>`)
// })
// //msg.reply(`My darling is <@${result.userID}>`)
// } else {
// console.error()
// }
}
};
|