/[sudobot]/trunk/src/services/Verification.ts
ViewVC logotype

Contents of /trunk/src/services/Verification.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 127 - (show annotations)
Mon Jul 29 17:28:42 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: application/typescript
File size: 2703 byte(s)
Added verification system
1 import { GuildMember } from "discord.js";
2 import { Op } from "sequelize";
3 import DiscordClient from "../client/Client";
4 import MessageEmbed from "../client/MessageEmbed";
5
6 export default class Verification {
7 constructor(protected client: DiscordClient) {
8
9 }
10
11 async success(member: GuildMember) {
12 await member.roles.remove(this.client.config.props[member.guild.id].verification.role);
13
14 await member.send({
15 embeds: [
16 new MessageEmbed({
17 author: {
18 name: member.guild.name,
19 iconURL: member.guild.iconURL() ?? undefined,
20 },
21 title: "Thanks for verifying!",
22 description: "The verification was completed successfully!",
23 timestamp: new Date()
24 })
25 ],
26 });
27
28 const { default: UnverifiedMember } = await import('../models/UnverifiedMember');
29
30 const data = await UnverifiedMember.findOne({
31 where: {
32 guild_id: member.guild.id,
33 user_id: member.id,
34 status: 'pending'
35 }
36 });
37
38 await data?.set('status', 'done');
39 await data?.save();
40 }
41
42 async start(member: GuildMember) {
43 const { default: UnverifiedMember } = await import('../models/UnverifiedMember');
44
45 await UnverifiedMember.create({
46 guild_id: member.guild.id,
47 user_id: member.id,
48 status: 'pending'
49 });
50
51 await member.roles.add(this.client.config.props[member.guild.id].verification.role);
52
53 const url = `${this.client.config.props.global.cp_host}/challenge/v1/verify/?guild_id=${member.guild.id}`;
54
55 await member.send({
56 embeds: [
57 new MessageEmbed({
58 author: {
59 name: member.guild.name,
60 iconURL: member.guild.iconURL() ?? undefined,
61 },
62 title: "Verification Required!",
63 description: `Hey ${member.nickname ?? member.user.username}, the server **${member.guild.name}** requires verification!\nTo verify yourself, simply go to the verification URL given below and you might be asked to solve some captcha.\n\nHave a nice day,\n*${member.guild.name} Staff*`,
64 timestamp: new Date(),
65 fields: [
66 {
67 name: "Verification URL",
68 value: url
69 }
70 ],
71 url
72 })
73 ]
74 });
75 }
76 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26