|
|
|
@ -1,5 +1,5 @@
|
|
|
|
import { LoadingEmbed } from "../../utils/defaults.js";
|
|
|
|
import { LoadingEmbed } from "../../utils/defaults.js";
|
|
|
|
import Discord, { CommandInteraction, ActionRowBuilder, ButtonBuilder, TextInputComponent, Role, ButtonStyle } from "discord.js";
|
|
|
|
import Discord, { CommandInteraction, ActionRowBuilder, ButtonBuilder, TextInputComponent, Role, ButtonStyle, ButtonComponent, TextInputBuilder } from "discord.js";
|
|
|
|
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
|
|
|
|
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
|
|
|
|
import getEmojiByName from "../../utils/getEmojiByName.js";
|
|
|
|
import getEmojiByName from "../../utils/getEmojiByName.js";
|
|
|
|
import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
|
|
|
import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
|
|
|
@ -35,15 +35,15 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
|
|
|
|
.send(true);
|
|
|
|
.send(true);
|
|
|
|
if (confirmation.cancelled) return
|
|
|
|
if (confirmation.cancelled) return
|
|
|
|
if (confirmation.success) {
|
|
|
|
if (confirmation.success) {
|
|
|
|
await client.database.guilds.write(interaction!.guild.id, {
|
|
|
|
await client.database.guilds.write(interaction.guild!.id, {
|
|
|
|
["moderation.mute.role"]: (interaction.options.get("role") as unknown as Role).id
|
|
|
|
["moderation.mute.role"]: (interaction.options.get("role") as unknown as Role).id
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let timedOut = false;
|
|
|
|
let timedOut = false;
|
|
|
|
while (!timedOut) {
|
|
|
|
while (!timedOut) {
|
|
|
|
const config = await client.database.guilds.read(interaction!.guild.id);
|
|
|
|
const config = await client.database.guilds.read(interaction.guild!.id);
|
|
|
|
const moderation = config.getKey("moderation");
|
|
|
|
const moderation = config["moderation"];
|
|
|
|
m = await interaction.editReply({
|
|
|
|
m = await interaction.editReply({
|
|
|
|
embeds: [
|
|
|
|
embeds: [
|
|
|
|
new EmojiEmbed()
|
|
|
|
new EmojiEmbed()
|
|
|
|
@ -57,7 +57,7 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
],
|
|
|
|
],
|
|
|
|
components: [
|
|
|
|
components: [
|
|
|
|
new ActionRowBuilder().addComponents([
|
|
|
|
new ActionRowBuilder<ButtonBuilder>().addComponents([
|
|
|
|
new ButtonBuilder()
|
|
|
|
new ButtonBuilder()
|
|
|
|
.setLabel("Warn")
|
|
|
|
.setLabel("Warn")
|
|
|
|
.setEmoji(getEmojiByName("PUNISH.WARN.YELLOW", "id"))
|
|
|
|
.setEmoji(getEmojiByName("PUNISH.WARN.YELLOW", "id"))
|
|
|
|
@ -74,7 +74,7 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
|
|
|
|
.setCustomId("nickname")
|
|
|
|
.setCustomId("nickname")
|
|
|
|
.setStyle(ButtonStyle.Secondary)
|
|
|
|
.setStyle(ButtonStyle.Secondary)
|
|
|
|
]),
|
|
|
|
]),
|
|
|
|
new ActionRowBuilder().addComponents([
|
|
|
|
new ActionRowBuilder<ButtonBuilder>().addComponents([
|
|
|
|
new ButtonBuilder()
|
|
|
|
new ButtonBuilder()
|
|
|
|
.setLabel("Kick")
|
|
|
|
.setLabel("Kick")
|
|
|
|
.setEmoji(getEmojiByName("PUNISH.KICK.RED", "id"))
|
|
|
|
.setEmoji(getEmojiByName("PUNISH.KICK.RED", "id"))
|
|
|
|
@ -91,7 +91,7 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
|
|
|
|
.setCustomId("ban")
|
|
|
|
.setCustomId("ban")
|
|
|
|
.setStyle(ButtonStyle.Secondary)
|
|
|
|
.setStyle(ButtonStyle.Secondary)
|
|
|
|
]),
|
|
|
|
]),
|
|
|
|
new ActionRowBuilder().addComponents([
|
|
|
|
new ActionRowBuilder<ButtonBuilder>().addComponents([
|
|
|
|
new ButtonBuilder()
|
|
|
|
new ButtonBuilder()
|
|
|
|
.setLabel(clicked === "clearMuteRole" ? "Click again to confirm" : "Clear mute role")
|
|
|
|
.setLabel(clicked === "clearMuteRole" ? "Click again to confirm" : "Clear mute role")
|
|
|
|
.setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
|
|
|
|
.setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
|
|
|
|
@ -116,11 +116,12 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
|
|
|
|
timedOut = true;
|
|
|
|
timedOut = true;
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let chosen = moderation[i.customId] ?? { text: null, url: null };
|
|
|
|
type modIDs = "mute" | "kick" | "ban" | "softban" | "warn" | "role";
|
|
|
|
if (i.component.customId === "clearMuteRole") {
|
|
|
|
let chosen = moderation[i.customId as modIDs] ?? { text: null, url: null };
|
|
|
|
|
|
|
|
if ((i.component as ButtonComponent).customId === "clearMuteRole") {
|
|
|
|
i.deferUpdate();
|
|
|
|
i.deferUpdate();
|
|
|
|
if (clicked === "clearMuteRole") {
|
|
|
|
if (clicked === "clearMuteRole") {
|
|
|
|
await client.database.guilds.write(interaction.guild.id, {
|
|
|
|
await client.database.guilds.write(interaction.guild!.id, {
|
|
|
|
"moderation.mute.role": null
|
|
|
|
"moderation.mute.role": null
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -130,36 +131,36 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
clicked = "";
|
|
|
|
clicked = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i.component.customId === "timeout") {
|
|
|
|
if ((i.component as ButtonComponent).customId === "timeout") {
|
|
|
|
await i.deferUpdate();
|
|
|
|
await i.deferUpdate();
|
|
|
|
await client.database.guilds.write(interaction.guild.id, {
|
|
|
|
await client.database.guilds.write(interaction.guild!.id, {
|
|
|
|
"moderation.mute.timeout": !moderation.mute.timeout
|
|
|
|
"moderation.mute.timeout": !moderation.mute.timeout
|
|
|
|
});
|
|
|
|
});
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
} else if (i.customId) {
|
|
|
|
} else if (i.customId) {
|
|
|
|
await i.showModal(
|
|
|
|
await i.showModal(
|
|
|
|
new Discord.Modal()
|
|
|
|
new Discord.ModalBuilder()
|
|
|
|
.setCustomId("modal")
|
|
|
|
.setCustomId("modal")
|
|
|
|
.setTitle(`Options for ${i.customId}`)
|
|
|
|
.setTitle(`Options for ${i.customId}`)
|
|
|
|
.addComponents(
|
|
|
|
.addComponents(
|
|
|
|
new ActionRowBuilder<TextInputComponent>().addComponents(
|
|
|
|
new ActionRowBuilder<TextInputBuilder>().addComponents(
|
|
|
|
new TextInputComponent()
|
|
|
|
new TextInputBuilder()
|
|
|
|
.setCustomId("name")
|
|
|
|
.setCustomId("name")
|
|
|
|
.setLabel("Button text")
|
|
|
|
.setLabel("Button text")
|
|
|
|
.setMaxLength(100)
|
|
|
|
.setMaxLength(100)
|
|
|
|
.setRequired(false)
|
|
|
|
.setRequired(false)
|
|
|
|
.setStyle("SHORT")
|
|
|
|
.setStyle(Discord.TextInputStyle.Short)
|
|
|
|
.setValue(chosen.text ?? "")
|
|
|
|
.setValue(chosen.text ?? "")
|
|
|
|
),
|
|
|
|
).toJSON(),
|
|
|
|
new ActionRowBuilder<TextInputComponent>().addComponents(
|
|
|
|
new ActionRowBuilder<TextInputBuilder>().addComponents(
|
|
|
|
new TextInputComponent()
|
|
|
|
new TextInputBuilder()
|
|
|
|
.setCustomId("url")
|
|
|
|
.setCustomId("url")
|
|
|
|
.setLabel("URL - Type {id} to insert the user's ID")
|
|
|
|
.setLabel("URL - Type {id} to insert the user's ID")
|
|
|
|
.setMaxLength(2000)
|
|
|
|
.setMaxLength(2000)
|
|
|
|
.setRequired(false)
|
|
|
|
.setRequired(false)
|
|
|
|
.setStyle("SHORT")
|
|
|
|
.setStyle(Discord.TextInputStyle.Short)
|
|
|
|
.setValue(chosen.link ?? "")
|
|
|
|
.setValue(chosen.link ?? "")
|
|
|
|
)
|
|
|
|
).toJSON()
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
await interaction.editReply({
|
|
|
|
await interaction.editReply({
|
|
|
|
@ -171,7 +172,7 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
|
|
|
|
.setEmoji("GUILD.TICKET.OPEN")
|
|
|
|
.setEmoji("GUILD.TICKET.OPEN")
|
|
|
|
],
|
|
|
|
],
|
|
|
|
components: [
|
|
|
|
components: [
|
|
|
|
new ActionRowBuilder().addComponents([
|
|
|
|
new ActionRowBuilder<ButtonBuilder>().addComponents([
|
|
|
|
new ButtonBuilder()
|
|
|
|
new ButtonBuilder()
|
|
|
|
.setLabel("Back")
|
|
|
|
.setLabel("Back")
|
|
|
|
.setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
|
|
|
|
.setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
|
|
|
|
@ -180,23 +181,23 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
|
|
|
|
])
|
|
|
|
])
|
|
|
|
]
|
|
|
|
]
|
|
|
|
});
|
|
|
|
});
|
|
|
|
let out;
|
|
|
|
let out: Discord.ModalSubmitInteraction;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
out = await modalInteractionCollector(
|
|
|
|
out = await modalInteractionCollector(
|
|
|
|
m,
|
|
|
|
m,
|
|
|
|
(m) => m.channel.id === interaction.channel.id,
|
|
|
|
(m) => m.channel!.id === interaction.channel!.id,
|
|
|
|
(_) => true
|
|
|
|
(_) => true
|
|
|
|
);
|
|
|
|
) as Discord.ModalSubmitInteraction;
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (out.fields) {
|
|
|
|
if ((out!).fields) {
|
|
|
|
const buttonText = out.fields.getTextInputValue("name");
|
|
|
|
const buttonText = out.fields.getTextInputValue("name");
|
|
|
|
const buttonLink = out.fields.getTextInputValue("url").replace(/{id}/gi, "{id}");
|
|
|
|
const buttonLink = out.fields.getTextInputValue("url").replace(/{id}/gi, "{id}");
|
|
|
|
const current = chosen;
|
|
|
|
const current = chosen;
|
|
|
|
if (current.text !== buttonText || current.link !== buttonLink) {
|
|
|
|
if (current.text !== buttonText || current.link !== buttonLink) {
|
|
|
|
chosen = { text: buttonText, link: buttonLink };
|
|
|
|
chosen = { text: buttonText, link: buttonLink };
|
|
|
|
await client.database.guilds.write(interaction.guild.id, {
|
|
|
|
await client.database.guilds.write(interaction.guild!.id, {
|
|
|
|
["moderation." + i.customId]: {
|
|
|
|
["moderation." + i.customId]: {
|
|
|
|
text: buttonText,
|
|
|
|
text: buttonText,
|
|
|
|
link: buttonLink
|
|
|
|
link: buttonLink
|
|
|
|
|