-
Notifications
You must be signed in to change notification settings - Fork 0
/
verify.js
200 lines (186 loc) · 6.33 KB
/
verify.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
const {
Client,
MessageEmbed,
MessageButton,
MessageActionRow,
MessageAttachment,
} = require("discord.js");
const config = require("./config");
const { Captcha } = require("captcha-canvas");
const captcha = new Captcha();
/**
*
* @param {Client} client
*/
module.exports = async (client) => {
// code
client.on("interactionCreate", async (interaction) => {
if (interaction.isCommand()) {
if (interaction.commandName == "ping") {
interaction.reply({
content: `My latency - ${client.ws.ping}`,
ephemeral: true,
});
} else if (interaction.commandName == "setup") {
if (!interaction.member.permissions.has("MANAGE_ROLES")) {
return interaction.reply({
content: `you don't have perms to run command`,
ephemeral: true,
});
}
let verifyChannel = interaction.guild.channels.cache.get(
config.verifyChannel
);
let verifyRole = interaction.guild.roles.cache.get(config.verifyRole);
if (!verifyChannel || !verifyRole) {
return interaction.reply({
content: `verifyChannel and VerifyRole is not found`,
ephemeral: true,
});
} else {
let embed = new MessageEmbed()
.setColor("BLURPLE")
.setTitle(`Verification System of ${interaction.guild.name}`);
let btnrow = new MessageActionRow().addComponents([
new MessageButton()
.setCustomId(`v_ping`)
.setLabel("Ping me !!")
.setStyle("PRIMARY")
.setEmoji("📶"),
new MessageButton()
.setCustomId(`v_verify`)
.setLabel("Verify")
.setStyle("SUCCESS")
.setEmoji("📑"),
]);
await verifyChannel.send({
embeds: [embed],
components: [btnrow],
});
// changing permissions
let role = interaction.guild.roles.everyone;
interaction.guild.channels.cache
.filter((ch) => ch.id !== verifyChannel.id)
.forEach(async (ch) => {
// changing perms of every role
await ch.permissionOverwrites.edit(role, {
SEND_MESSAGES: false,
VIEW_CHANNEL: false,
READ_MESSAGE_HISTORY: false,
CONNECT: false,
});
// giving perms to client;
await ch.permissionOverwrites.edit(client.user.id, {
SEND_MESSAGES: true,
VIEW_CHANNEL: true,
READ_MESSAGE_HISTORY: true,
CONNECT: true,
MANAGE_CHANNELS: true,
MANAGE_ROLES: true,
});
// adding perms for verify role
await ch.permissionOverwrites.edit(verifyRole, {
SEND_MESSAGES: true,
VIEW_CHANNEL: true,
READ_MESSAGE_HISTORY: true,
CONNECT: true,
});
});
interaction.reply({
content: `Verification System Setup in ${verifyChannel} and Verify Role is ${verifyRole}`,
ephemeral: true,
});
}
} else {
interaction.reply({
content: `${interaction.commandName} is not valid`,
ephemeral: true,
});
}
}
if (interaction.isButton()) {
if (interaction.customId == "v_ping") {
return interaction.reply({
content: `i am working fine`,
ephemeral: true,
});
} else if (interaction.customId == "v_verify") {
// code
let verifyRole = interaction.guild.roles.cache.get(config.verifyRole);
if (!verifyRole) return;
if (interaction.member.roles.cache.has(verifyRole.id)) {
return interaction.reply({
content: `you are already verified`,
ephemeral: true,
});
} else {
if (!interaction.guild.me.permissions.has("MANAGE_ROLES")) {
return interaction.reply({
content: `i don't have perms`,
ephemeral: true,
});
}
// creatings captcha
captcha.async = true;
captcha.addDecoy();
captcha.drawTrace();
captcha.drawCaptcha();
const captchaImage = new MessageAttachment(
await captcha.png,
"captcha.png"
);
let cmsg = await interaction.user.send({
embeds: [
new MessageEmbed()
.setColor("BLUE")
.setTitle(`Captcha Verification`)
.setImage(`attachment://captcha.png`),
],
files: [captchaImage],
});
interaction.reply({
content: `Hey! Please check you'r dm's i have sent you the captcha to verify yourself in this server!`,
ephemeral: true,
});
await cmsg.channel
.awaitMessages({
filter: (m) => m.author.id == interaction.user.id,
max: 1,
time: 1000 * 60,
errors: ["time"],
})
.then(async (value) => {
let isValid = value.first().content == captcha.text;
if (isValid) {
await interaction.member.roles.add(verifyRole).catch((e) => {});
interaction.user.send({
content: `🎉 You have verified! Now you have got access of this server!`,
ephemeral: true,
});
} else {
await interaction.user.send(
`💀 You're kicked from ${intercation.guild.name}! Because you did not completed the captcha :/`
);
interaction.member.kick().catch((e) => {});
}
})
.catch(async (e) => {
await interaction.user.send(
`💀 You're kicked from ${intercation.guild.name}! Because you did not completed the captcha :/`
);
interaction.member.kick().catch((e) => {});
});
}
}
}
});
};
/**
* @INFO
* Bot Coded by iRed#1330 | https://github.com/iRed-Github/Verification-BOT
* @INFO
* Join iDK Development | https://dsc.gg/idk-development
* @INFO
* Please mention Her / iDK Development, when using this Code!
* @INFO
*/