-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
748 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
TOKEN=your-bot-token | ||
DEEPL_API_KEY=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX:fx | ||
MONGO_URI=mongodb+srv://username:password@clusterName.6bo3a.mongodb.net/Data | ||
MONGO_URI=mongodb+srv://username:password@clusterName.xxxxx.mongodb.net/Data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
const { Button } = require("sheweny"); | ||
const { PermissionFlagsBits } = require("discord.js"); | ||
|
||
module.exports = class verifyButton extends Button { | ||
constructor(client) { | ||
super(client, ["verify", /verify-.*/, "verify-edit"]); | ||
} | ||
|
||
async execute(button) { | ||
const { guild, member } = button; | ||
const { fetchGuild, lang } = await this.client.FetchAndGetLang(guild); | ||
const { errors } = this.client.la[lang]; | ||
const { verify } = this.client.la[lang].interactions.buttons; | ||
|
||
const me = await guild.members.fetchMe(); | ||
const requiredPerms = ["ManageRoles"]; | ||
|
||
if (!me.permissions.has(PermissionFlagsBits.ManageRoles)) | ||
return selectMenu.editReply({ | ||
content: eval(errors.error52), | ||
}); | ||
|
||
const role = guild.roles.cache.get(fetchGuild.verify.role); | ||
if (!role) | ||
return button.editReply({ | ||
content: errors.error54, | ||
}); | ||
|
||
switch (button.customId) { | ||
case "verify": | ||
if (!(await this.client.Defer(button))) return; | ||
|
||
// check the member verification | ||
if (member.roles.cache.has(role.id)) | ||
return button.editReply({ | ||
content: verify.alreadyVerified, | ||
}); | ||
|
||
// check if the captcha is disabled | ||
if (!fetchGuild.moderationTools.enabled.includes("verifyCaptcha")) { | ||
member.roles.add(role).catch(() => undefined); | ||
return button.editReply({ content: verify.reply1 }); | ||
} | ||
|
||
// generate sequence and send it with the button id | ||
const sequence = await this.client.GenerateCaptcha(); | ||
button.editReply({ | ||
embeds: [ | ||
this.client | ||
.Embed() | ||
.setTitle(verify.embed1.title) | ||
.setDescription(verify.embed1.description) | ||
.setFields({ | ||
name: verify.embed1.field1, | ||
value: `\`\`\`${sequence}\`\`\``, | ||
}), | ||
], | ||
components: [ | ||
this.client.ButtonRow([ | ||
{ | ||
customId: `verify-${sequence}`, | ||
label: verify.button1, | ||
style: "SECONDARY", | ||
emoji: "🤖", | ||
}, | ||
]), | ||
], | ||
}); | ||
break; | ||
|
||
case "verify-edit": | ||
if (!(await this.client.Defer(button))) return; | ||
|
||
button.editReply({ | ||
content: verify.reply2, | ||
components: [ | ||
this.client.ButtonRow([ | ||
{ | ||
customId: "verify-captcha-tool-enable", | ||
label: verify.button2, | ||
style: "SECONDARY", | ||
emoji: "✅", | ||
}, | ||
{ | ||
customId: "verify-captcha-tool-disable", | ||
label: verify.button3, | ||
style: "SECONDARY", | ||
emoji: "❌", | ||
}, | ||
]), | ||
], | ||
}); | ||
break; | ||
|
||
case button.customId.match(/verify\-.{5}/g)[0]: // verify-xxxxx | ||
// get the sequence and send it with the modal id | ||
const sendSequence = button.customId.split("-")[1]; | ||
await button.showModal( | ||
this.client.ModalRow(`verify-${sendSequence}`, verify.modal1.title, [ | ||
{ | ||
customId: "verify-input", | ||
label: verify.modal1.field1, | ||
style: "Short", | ||
placeholder: `${sendSequence}`, | ||
required: true, | ||
}, | ||
]) | ||
); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const { Modal } = require("sheweny"); | ||
|
||
module.exports = class verifyModal extends Modal { | ||
constructor(client) { | ||
super(client, [/verify-.*/]); | ||
} | ||
|
||
async execute(modal) { | ||
const { guild, user, customId, fields } = modal; | ||
|
||
const { fetchGuild, lang } = await this.client.FetchAndGetLang(guild); | ||
const { errors } = this.client.la[lang]; | ||
const { verify } = this.client.la[lang].interactions.modals; | ||
|
||
const userSequence = fields.getTextInputValue("verify-input"); | ||
|
||
const role = guild.roles.cache.get(fetchGuild.verify.role); | ||
if (!role) | ||
return modal.editReply({ | ||
content: errors.error54, | ||
}); | ||
const member = guild.members.cache.get(user.id); | ||
|
||
// check if the entered sequence is correct | ||
if (!userSequence === customId.split("-")[1]) { | ||
modal.reply({ | ||
content: verify.badCode, | ||
ephemeral: true, | ||
}); | ||
} | ||
|
||
// check the member verification | ||
if (member.roles.cache.has(role.id)) { | ||
return modal.reply({ | ||
content: verify.alreadyVerified, | ||
ephemeral: true, | ||
}); | ||
} | ||
|
||
// add the role | ||
member.roles.add(role); | ||
modal.reply({ | ||
content: verify.reply, | ||
ephemeral: true, | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.