loads of new commands, updates and bug fixes
diff --git a/src/commands/settings/verify/role.ts b/src/commands/settings/verify/role.ts
index c4de7af..dc1d4d9 100644
--- a/src/commands/settings/verify/role.ts
+++ b/src/commands/settings/verify/role.ts
@@ -1,20 +1,126 @@
-import { CommandInteraction } from "discord.js";
+import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
+import generateEmojiEmbed from "../../../utils/generateEmojiEmbed.js";
+import confirmationMessage from "../../../utils/confirmationMessage.js";
+import getEmojiByName from "../../../utils/getEmojiByName.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
+import client from "../../../utils/client.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("role")
- .setDescription("Sets the role given after verifying")
+ .setDescription("Sets or shows the role given to users after using /verify")
+ .addRoleOption(option => option.setName("role").setDescription("The role to give after verifying"))
-const callback = (interaction: CommandInteraction) => {
- interaction.reply("This command is not yet finished [settings/verify/role]");
+const callback = async (interaction: CommandInteraction): Promise<any> => {
+ let m;
+ m = await interaction.reply({embeds: [new generateEmojiEmbed()
+ .setTitle("Loading")
+ .setStatus("Danger")
+ .setEmoji("NUCLEUS.LOADING")
+ ], ephemeral: true, fetchReply: true});
+ if (interaction.options.getRole("role")) {
+ let role
+ try {
+ role = interaction.options.getRole("role")
+ } catch {
+ return await interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setEmoji("GUILD.ROLES.DELETE")
+ .setTitle("Verify Role")
+ .setDescription("The role you provided is not a valid role")
+ .setStatus("Danger")
+ ]})
+ }
+ role = role as Discord.Role
+ if (role.guild.id != interaction.guild.id) {
+ return interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setTitle("Verify Role")
+ .setDescription(`You must choose a role in this server`)
+ .setStatus("Danger")
+ .setEmoji("GUILD.ROLES.DELETE")
+ ]});
+ }
+ let confirmation = await new confirmationMessage(interaction)
+ .setEmoji("GUILD.ROLES.EDIT")
+ .setTitle("Verify Role")
+ .setDescription(`Are you sure you want to set the verify role to <@&${role.id}>?`)
+ .setColor("Warning")
+ .setInverted(true)
+ .send(true)
+ if (confirmation.success) {
+ try {
+ await client.database.write(interaction.guild.id, {"verify.role": role.id, "verify.enabled": true});
+ } catch (e) {
+ console.log(e)
+ return interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setTitle("Verify Role")
+ .setDescription(`Something went wrong while setting the verify role`)
+ .setStatus("Danger")
+ .setEmoji("GUILD.ROLES.DELETE")
+ ], components: []});
+ }
+ } else {
+ return interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setTitle("Verify Role")
+ .setDescription(`No changes were made`)
+ .setStatus("Success")
+ .setEmoji("GUILD.ROLES.CREATE")
+ ], components: []});
+ }
+ }
+ let clicks = 0;
+ let data = await client.database.read(interaction.guild.id);
+ let role = data.verify.role;
+ while (true) {
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setTitle("Verify Role")
+ .setDescription(role ? `Your verify role is currently set to <@&${role}>` : `You have not set a verify role`)
+ .setStatus("Success")
+ .setEmoji("GUILD.ROLES.CREATE")
+ ], components: [new MessageActionRow().addComponents([new MessageButton()
+ .setCustomId("clear")
+ .setLabel(clicks ? "Click again to confirm" : "Reset role")
+ .setEmoji(getEmojiByName(clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS", "id"))
+ .setStyle("DANGER")
+ .setDisabled(!role)
+ ])]});
+ let i;
+ try {
+ i = await m.awaitMessageComponent({time: 600000});
+ } catch(e) { break }
+ i.deferUpdate()
+ if (i.component.customId == "clear") {
+ clicks += 1;
+ if (clicks == 2) {
+ clicks = 0;
+ await client.database.write(interaction.guild.id, {}, ["verify.role", "verify.enabled"])
+ role = undefined;
+ }
+ } else {
+ break
+ }
+ }
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setTitle("Verify Role")
+ .setDescription(role ? `Your verify role is currently set to <@&${role}}>` : `You have not set a verify role`)
+ .setStatus("Success")
+ .setEmoji("GUILD.ROLE.CREATE")
+ .setFooter({text: "Message closed"})
+ ], components: [new MessageActionRow().addComponents([new MessageButton()
+ .setCustomId("clear")
+ .setLabel("Clear")
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ .setStyle("SECONDARY")
+ .setDisabled(true)
+ ])]});
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
+ let member = (interaction.member as Discord.GuildMember)
+ if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the `manage_server` permission to use this command"
return true;
}
export { command };
export { callback };
-export { check };
\ No newline at end of file
+export { check };