import { Command, CommandoMessage, CommandoClient } from 'discord.js-commando'; //@ts-ignore import emoji from 'emoji-random'; import Verify from '../../models/Verify'; import mongo from 'mongoose'; import config from '../../config.json'; mongo.connect(config['mongodburi'], { useNewUrlParser: true, useUnifiedTopology: true }) module.exports = class VerifyEmma extends Command { constructor(client: CommandoClient) { super(client, { name: 'verify', group: 'emma', memberName: 'verify', description: 'Lists all the roles on the current server.', examples: ['uwu!verify set', 'uwu!verify remove'], throttling: { usages: 5, duration: 30 }, userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'], clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'], guildOnly: true, args: [ { key: 'code', prompt: 'What is the verification code?', type: 'string' } ] }); } //@ts-ignore this ok async run(msg: CommandoMessage, { code }: any) { if (msg.guild.id == '704032355987488791') return msg.reply(`You are not submitting from **Kat\'s Korner**! ${emoji.random()}`); Verify.findOne({ userID: msg.author.id }, async (error, member) => { if (error) return console.error(error) //@ts-ignore this exists if (msg.author.id == member.userID) { //@ts-ignore this in-fact if (code == member.key) { await Verify.findOneAndDelete({ userID: msg.author.id }); const unverRole = '729928740359897101'; return msg.guild.member(msg.author.id)?.roles.remove(unverRole); } else { //@ts-ignore this exists return msg.author.send(`That is not the correct key! Please try again with the correct key: \`${member.key}\`. ${emoji.random()}`); } } else { return msg.author.send(`You are already verified! ${emoji.random()}`) } }) } };