diff options
| author | 8cy <[email protected]> | 2020-07-26 07:02:25 -0700 |
|---|---|---|
| committer | 8cy <[email protected]> | 2020-07-26 07:02:25 -0700 |
| commit | 8a7f1253716c79e2d36d356b9ad380d382d8603e (patch) | |
| tree | 91281e6ce74752560c2c38ddc3587a6541370436 /server/src/commands | |
| parent | improvment: bold and tag darling check (diff) | |
| download | dep-core-test-captcha.tar.xz dep-core-test-captcha.zip | |
feat/ fix/ chore/ improvmenttest-captcha
feat:
- new img method on client
- verification command finally lul, this also had me add stuff to the config
fix:
- fanart msg now says "video/ img" instead of just video.
- re-add f reaction to leave msgs
chore:
- capitalize s in sending in help msg.
improvement:
- 3 new welcome msgs
- 4 new goodbye msgs
- make "1/ 1000" in secret msg bold and react with star emoji
Diffstat (limited to 'server/src/commands')
| -rw-r--r-- | server/src/commands/emma/FanArt.ts | 2 | ||||
| -rw-r--r-- | server/src/commands/emma/Verify.ts | 73 | ||||
| -rw-r--r-- | server/src/commands/util/Help.ts | 2 |
3 files changed, 75 insertions, 2 deletions
diff --git a/server/src/commands/emma/FanArt.ts b/server/src/commands/emma/FanArt.ts index 3cab365..3d04718 100644 --- a/server/src/commands/emma/FanArt.ts +++ b/server/src/commands/emma/FanArt.ts @@ -72,7 +72,7 @@ export default class FanArtEmma extends Command { msg.attachments.forEach(fanart => { if (fanart.url) { //@ts-ignore - return fanartServer.channels.cache.get(fanartChannel).send(`**New fanart submitted!**\nFanart by <@${msg.author.id}>.\n\n**Comment**\n${comment ? comment : 'None.'}\n\n**Video** ` + fanart.url) + return fanartServer.channels.cache.get(fanartChannel).send(`**New fanart submitted!**\nFanart by <@${msg.author.id}>.\n\n**Comment**\n${comment ? comment : 'None.'}\n\n**Video/ Image** ` + fanart.url) .then(m => { m.react('😍'); m.react('😂'); diff --git a/server/src/commands/emma/Verify.ts b/server/src/commands/emma/Verify.ts new file mode 100644 index 0000000..09bebbb --- /dev/null +++ b/server/src/commands/emma/Verify.ts @@ -0,0 +1,73 @@ +import { Command } from 'discord-akairo'; +import { Message } from 'discord.js'; +import { colour } from '../../Config'; +import * as svgCaptcha from 'svg-captcha'; +import { MessageAttachment } from 'discord.js'; +import { TextChannel } from 'discord.js'; +import { captchaSettings, verificationRole, verificationChannel } from '../../Config'; + +export default class VerifyEmma extends Command { + public constructor() { + super('verify', { + aliases: ['verify'], + category: 'moderation', + description: { + content: 'Allows to to verify yourself so you can access the rest of a server. Public version out soon!', + usage: '', + examples: [ + '' + ] + }, + ratelimit: 3 + }); + } + + public async exec(msg: Message): Promise<Message> { + msg.delete(); + if ((msg.channel as TextChannel).name !== verificationChannel) return; + if (msg.channel.type ==='dm') return msg.channel.send('Sorry, verification needs to be initialized in the server\'s verification channel!'); + const captcha = await svgCaptcha.create(captchaSettings); + const attachment = new MessageAttachment(await this.client.img(captcha.data).then(r => r), 'captcha.png'); + const embed = this.client.util.embed() + .setColor(colour) + .setDescription('Please reply with the following captcha. (**case-sensitive**).') + //@ts-ignore + .attachFiles(attachment) + .setImage('attachment://captcha.png') + .setFooter('Expires in 60 seconds.') + const m1 = await msg.author.send('Generating captcha...').catch(async () => { + const deleteMessage = await msg.reply('I\'m unable to send you a direct message. Please, make sure to allow direct messages from server members in the privacy settings!'); + await this.wait(7000); + return deleteMessage.delete(); + }); + m1.delete(); + const message = await msg.author.send(embed); + const response = await this.awaitReplyDM(msg.member, message, 60000); + if (!response) return msg.author.send(`The captcha has expired! Try again by typing \`${this.client.commandHandler.prefix}verify\` in the server's verification channel!`).catch(async () => { + const deleteMessage = await msg.reply('I\'m unable to send you a direct message. Please, make sure to allow direct messages from server members in the privacy settings!'); + await this.wait(7000); + return deleteMessage.delete(); + }); + if (response.includes(captcha.text)) { + msg.author.send('You passed the captcha! Granting access...').then(async m => { + const role = await msg.guild.roles.cache.find(r => r.name.toLowerCase() === verificationRole.toLowerCase()); + if (role) msg.member.roles.add(role.id); + m.edit(`Access granted to **${msg.guild.name}**!`); + }); + } else { + return msg.author.send(`Wrong captcha! Try again by typing \`${this.client.commandHandler.prefix}verify\` in the server's verification channel!`); + } + } + + public awaitReplyDM = async (member, msg, question, limit = 60000) => { + const filter = m => member.id == member.id; + try { + const collected = await msg.channel.awaitMessages(filter, { max: 1, time: limit, errors: ['time'] }); + return collected.first().content; + } catch (error) { + return false; + } + } + + public wait = require("util").promisify(setTimeout); +}
\ No newline at end of file diff --git a/server/src/commands/util/Help.ts b/server/src/commands/util/Help.ts index 76d2bf6..15549d5 100644 --- a/server/src/commands/util/Help.ts +++ b/server/src/commands/util/Help.ts @@ -92,7 +92,7 @@ export default class HelpUtil extends Command { } if (msg.channel.type === 'dm') return msg.author.send({ embed }); - return msg.reply('sending you a DM with information...').then(async m => { + return msg.reply('Sending you a DM with information...').then(async m => { await msg.author.send({ embed }); m.edit('I\'ve send you a DM with information!'); }); |