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/zerotwo/darling.ts | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src/commands/zerotwo/darling.ts') diff --git a/src/commands/zerotwo/darling.ts b/src/commands/zerotwo/darling.ts index 505df19..2f52ed4 100644 --- a/src/commands/zerotwo/darling.ts +++ b/src/commands/zerotwo/darling.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 Darling from '../../models/darling.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 DarlingZeroTwo extends Command { - constructor(client) { + constructor(client: CommandoClient) { super(client, { name: 'darling', group: 'zerotwo', @@ -34,7 +35,9 @@ module.exports = class DarlingZeroTwo extends Command { guildOnly: true }); } - async run(msg: CommandoMessage, { darlingName }) { + //TODO: this + //@ts-ignore this is not asnc + async run(msg: CommandoMessage, { darlingName }: any) { // this is actually a string const darling = new Darling({ _id: mongo.Types.ObjectId(), username: msg.author.username, @@ -47,20 +50,20 @@ module.exports = class DarlingZeroTwo extends Command { Darling.findOne({ guildID: msg.guild.id }, async (error, guild) => { if (error) { - console.log(error) + return 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 || msg.author.id == msg.guild.owner.id) { await Darling.findOneAndDelete({ guildID: msg.guild.id }) - msg.say('The current darling has been removed. ' + emoji.random()) + return msg.say('The current darling has been removed. ' + emoji.random()) } else { - msg.reply('Only my darling or the guild owner can remove the current darling. ' + emoji.random()) + return msg.reply('Only my darling or the guild owner can remove the current darling. ' + emoji.random()) } } else if (!guild && darlingName == 'remove') { - msg.reply('There is no darling set in this server. ' + emoji.random()) + return 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}>! To set a new darling, either the current darling or the guild owner has to do \`uwu!darling remove\`. ` + emoji.random()) + return msg.reply(`I already have a darling! It\'s <@${guild.userID}>! To set a new darling, either the current darling or the guild owner has to do \`uwu!darling remove\`. ` + emoji.random()) } else if (!guild && darlingName == 'set') { await darling.save() .then(result => console.log(result)) @@ -72,12 +75,12 @@ module.exports = class DarlingZeroTwo extends Command { '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) + return msg.reply(quoteNum) } else if (!guild) { - msg.reply('I haven\'t found my darling yet! To set one, do `uwu!darling set`. ' + emoji.random()) + return 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()) + return msg.reply(`My darling is <@${guild.userID}>. ` + emoji.random()) } }) -- cgit v1.2.3