Did a little mischievous stuff.

This commit is contained in:
Kwafuri
2024-02-04 12:29:19 +00:00
parent 477fda20a0
commit babf037af9
2 changed files with 8 additions and 11 deletions
+1 -1
View File
@@ -24,6 +24,6 @@ module.exports = {
'alreadyVerified': 'You are already verified.', 'alreadyVerified': 'You are already verified.',
'tookTooLong': 'You took too long to respond. Please try again.', 'tookTooLong': 'You took too long to respond. Please try again.',
'unableToDM': 'I was unable to send you a DM. Please make sure "Allow Direct Message" for this guild is enabled.', 'unableToDM': 'I was unable to send you a DM. Please make sure "Allow Direct Message" for this guild is enabled.',
'maxAttemptsExceeded': 'You have run out of attempts!' 'maxAttemptsExceeded': 'Verification failed. You have run out of attempts!'
} }
} }
+7 -10
View File
@@ -1,7 +1,7 @@
const { EmbedBuilder, ApplicationCommandType, Collection, AttachmentBuilder } = require('discord.js'); const { EmbedBuilder, ApplicationCommandType, Collection, AttachmentBuilder } = require('discord.js');
const { createCanvas, loadImage } = require('canvas'); const { createCanvas, loadImage } = require('canvas');
const cfg = require('../../config/config.js'); const cfg = require('../../config/config.js');
const captchaUser = new Collection();
module.exports = { module.exports = {
name: 'verify', name: 'verify',
description: 'To verify yourself.', description: 'To verify yourself.',
@@ -14,8 +14,6 @@ module.exports = {
var lowchars = "abcdefghijklmnopqrstuvwxyz"; var lowchars = "abcdefghijklmnopqrstuvwxyz";
var nums = "0123456789"; var nums = "0123456789";
//get a random letter/number from upchars, lowchars, and nums
var chars = upchars + lowchars + nums;
var captcha = ""; var captcha = "";
for (var i = 0; i < count; i++) { for (var i = 0; i < count; i++) {
@@ -45,12 +43,14 @@ module.exports = {
return buffer; return buffer;
} }
await interaction.deferReply({ ephemeral: true });
if (interaction.channel.id !== cfg.guilds[guildId].channelId) { if (interaction.channel.id !== cfg.guilds[guildId].channelId) {
return interaction.reply({ content: cfg.messages.wrongChannel, ephemeral: true }) return interaction.editReply({ content: cfg.messages.wrongChannel, ephemeral: true })
} }
if (interaction.member.roles.cache.has(cfg.guilds[guildId].roleToAdd)) { if (interaction.member.roles.cache.has(cfg.guilds[guildId].roleToAdd)) {
return interaction.reply({ content: cfg.messages.alreadyVerified, ephemeral: true }) return interaction.editReply({ content: cfg.messages.alreadyVerified, ephemeral: true })
} }
let attempts = 0; let attempts = 0;
@@ -73,13 +73,11 @@ module.exports = {
.setColor('Green') .setColor('Green')
.setImage('attachment://captcha.png') .setImage('attachment://captcha.png')
.setTimestamp(); .setTimestamp();
if (attempts > 1) {
await interaction.user.send(cfg.messages.fail);
}
await interaction.user.send({ await interaction.user.send({
embeds: [embed], files: [attachment] embeds: [embed], files: [attachment]
}).then(async (msg) => { }).then(async (msg) => {
await interaction.editReply({ content: cfg.messages.toVerify, ephemeral: true });
const filter = m => !m.author.bot && m.author.id === interaction.user.id && m.channel.id === msg.channel.id; const filter = m => !m.author.bot && m.author.id === interaction.user.id && m.channel.id === msg.channel.id;
const collector = msg.channel.createMessageCollector({ const collector = msg.channel.createMessageCollector({
filter, filter,
@@ -92,7 +90,6 @@ module.exports = {
await interaction.user.send(cfg.messages.userLeft); await interaction.user.send(cfg.messages.userLeft);
collector.stop(); collector.stop();
} else { } else {
if (m.content === captcha) { if (m.content === captcha) {
validated = true; validated = true;
await interaction.member.roles.add(cfg.guilds[guildId].roleToAdd); await interaction.member.roles.add(cfg.guilds[guildId].roleToAdd);
@@ -117,7 +114,7 @@ module.exports = {
}); });
}).catch(async (err) => { }).catch(async (err) => {
await interaction.reply({ await interaction.editReply({
content: cfg.messages.unableToDM, content: cfg.messages.unableToDM,
ephemeral: true ephemeral: true
}); });