summaryrefslogtreecommitdiff
path: root/src/commands/server/welcome.ts
diff options
context:
space:
mode:
author8cy <[email protected]>2020-06-27 22:52:54 -0700
committer8cy <[email protected]>2020-06-27 22:52:54 -0700
commit80951013e391aab140800e4f386867e6c391553f (patch)
tree3d7101237ef1cd8d6fe2a2fab751a2dc55ae7d84 /src/commands/server/welcome.ts
parentmore config shit (diff)
downloaddep-core-80951013e391aab140800e4f386867e6c391553f.tar.xz
dep-core-80951013e391aab140800e4f386867e6c391553f.zip
add ts defs so not a lot of errors left
- made .todo file for epic error tracking
Diffstat (limited to 'src/commands/server/welcome.ts')
-rw-r--r--src/commands/server/welcome.ts36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/commands/server/welcome.ts b/src/commands/server/welcome.ts
index e2a197d..68b3046 100644
--- a/src/commands/server/welcome.ts
+++ b/src/commands/server/welcome.ts
@@ -1,4 +1,5 @@
-import { Command, CommandoMessage } from 'discord.js-commando';
+import { Command, CommandoMessage, CommandoClient } from 'discord.js-commando';
+//@ts-ignore no types
import emoji from 'emoji-random';
import Welcome from '../../models/welcome.js';
import mongo from 'mongoose';
@@ -6,7 +7,7 @@ import config from '../../config.json';
mongo.connect(config['mongodburi'], { useNewUrlParser: true, useUnifiedTopology: true })
module.exports = class WelcomeServer extends Command {
- constructor(client) {
+ constructor(client: CommandoClient) {
super(client, {
name: 'welcome',
group: 'server',
@@ -34,7 +35,8 @@ module.exports = class WelcomeServer extends Command {
guildOnly: true
});
}
- async run(msg: CommandoMessage, { wType }) {
+ //@ts-ignore doesnt matter if not all code paths return
+ async run(msg: CommandoMessage, { wType }: any) {
const welcome = new Welcome({
_id: mongo.Types.ObjectId(),
username: msg.author.username,
@@ -45,26 +47,33 @@ module.exports = class WelcomeServer extends Command {
channelID: msg.channel.id,
time: msg.createdAt
})
- const guildExist = await Welcome.findOne({ guildID: msg.guild.id })
+ // const guildExist = await Welcome.findOne({ guildID: msg.guild.id })
if (msg.member.hasPermission('MANAGE_GUILD')) {
Welcome.findOne({ guildID: msg.guild.id }, async (error, guild) => {
if (error) {
- console.log(error)
+ return console.log(error)
} else if (guild && wType == 'remove') {
await Welcome.findOneAndDelete({ guildID: msg.guild.id })
- msg.say('The current welcome channel has been unset! ' + emoji.random()).then(mnotif => {
+ return msg.say('The current welcome channel has been unset! ' + emoji.random()).then(mnotif => {
+ //@ts-ignore this exists
mnotif.delete({ timeout: 2000 })
+ //@ts-ignore this exists
msg.delete({ timeout: 2000 })
})
} else if (!guild && wType == 'remove') {
- msg.reply('There is no current welcome channel set for this guild! ' + emoji.random()).then(mnotif => {
+ return msg.reply('There is no current welcome channel set for this guild! ' + emoji.random()).then(mnotif => {
+ //@ts-ignore this exists
mnotif.delete({ timeout: 2000 })
+ //@ts-ignore this exists
msg.delete({ timeout: 2000 })
})
} else if (guild && wType == 'set') {
- msg.reply(`There already is a welcome channel set! It's ${guild.channelname}! ` + emoji.random()).then(mnotif => {
+ //@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 && wType == 'set') {
@@ -72,18 +81,21 @@ module.exports = class WelcomeServer extends Command {
.then(result => console.log(result))
.catch(err => console.log(err))
- msg.reply(`The welcome channel has been set to ${msg.channel}! ` + emoji.random()).then(mnotif => {
+ 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 (!guild) {
- msg.reply('There is no current welcome channel set for this guild! To set one, do `uwu!welcome set` in the channel you want to set it in. ' + emoji.random())
+ return msg.reply('There is no current welcome channel set for this guild! To set one, do `uwu!welcome set` in the channel you want to set it in. ' + emoji.random())
} else if (guild) {
- msg.reply(`The current welcome channel is ${guild.channelname}. ` + emoji.random())
+ //@ts-ignore this exists
+ return msg.reply(`The current welcome channel is ${guild.channelname}. ` + emoji.random())
}
})
} else {
- msg.reply('Insufficent permissions! ' + emoji.random())
+ return msg.reply('Insufficent permissions! ' + emoji.random())
}
}
}; \ No newline at end of file