From 80951013e391aab140800e4f386867e6c391553f Mon Sep 17 00:00:00 2001 From: 8cy <50817549+8cy@users.noreply.github.com> Date: Sat, 27 Jun 2020 22:52:54 -0700 Subject: add ts defs so not a lot of errors left - made .todo file for epic error tracking --- src/commands/server/welcome.ts | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'src/commands/server/welcome.ts') 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 -- cgit v1.2.3