moved to d.js 14.3.0, started fixing errors
Co-authored-by: PineappleFan <pineapplefanyt@gmail.com>
diff --git a/src/actions/roleMenu.ts b/src/actions/roleMenu.ts
index e7f1874..48ca49c 100644
--- a/src/actions/roleMenu.ts
+++ b/src/actions/roleMenu.ts
@@ -1,10 +1,11 @@
-import { Interaction, MessageButton } from "discord.js";
+import { Interaction, ButtonBuilder, CommandInteraction, Role, ButtonStyle } from "discord.js";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
-import { MessageActionRow, MessageSelectMenu } from "discord.js";
+import { ActionRowBuilder, SelectMenuBuilder } from "discord.js";
import getEmojiByName from "../utils/getEmojiByName.js";
import client from "../utils/client.js";
import { LoadingEmbed } from "../utils/defaultEmbeds.js";
import type { GuildConfig } from "../utils/database.js";
+import type { ButtonComponent } from "@discordjs/builders";
export interface RoleMenuSchema {
guild: string;
@@ -16,7 +17,9 @@
interaction: Interaction;
}
-export async function callback(interaction: Interaction) {
+export async function callback(interaction: CommandInteraction) {
+ if(!interaction.guild) return interaction.reply({ content: "This command can only be used in a server.", ephemeral: true });
+ if(!interaction.member) return interaction.reply({ content: "You must be in a server to use this command.", ephemeral: true });
const config = await client.database.guilds.read(interaction.guild.id);
if (!config.roleMenu.enabled)
return await interaction.reply({
@@ -67,7 +70,7 @@
client.roleMenu[code] = {
guild: interaction.guild.id,
guildName: interaction.guild.name,
- guildIcon: interaction.guild.iconURL({ format: "png" }),
+ guildIcon: interaction.guild.iconURL({ extension: "png" }),
user: interaction.member.user.id,
username: interaction.member.user.username,
data: config.roleMenu.options,
@@ -90,25 +93,26 @@
.setEmoji("GUILD.GREEN")
],
components: [
- new MessageActionRow().addComponents([
- new MessageButton()
+ new ActionRowBuilder().addComponents([
+ new ButtonBuilder()
.setLabel("Online")
- .setStyle("LINK")
+ .setStyle(ButtonStyle.Link)
.setDisabled(!up)
.setURL(`${client.config.baseUrl}nucleus/rolemenu?code=${code}`),
- new MessageButton().setLabel("Manual").setStyle("PRIMARY").setCustomId("manual")
+ new ButtonBuilder().setLabel("Manual").setStyle(ButtonStyle.Primary).setCustomId("manual")
])
]
});
}
let component;
+ if (!m) return;
try {
component = await m.awaitMessageComponent({ time: 300000 });
} catch (e) {
return;
}
component.deferUpdate();
- let rolesToAdd = [];
+ let rolesToAdd: Role[] = [];
for (let i = 0; i < config.roleMenu.options.length; i++) {
const object = config.roleMenu.options[i];
const m = await interaction.editReply({
@@ -129,19 +133,19 @@
})
],
components: [
- new MessageActionRow().addComponents(
+ new ActionRowBuilder().addComponents(
[
- new MessageButton()
+ new ButtonBuilder()
.setLabel("Cancel")
- .setStyle("DANGER")
+ .setStyle(ButtonStyle.Danger)
.setCustomId("cancel")
.setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
].concat(
object.min === 0
? [
- new MessageButton()
+ new ButtonBuilder()
.setLabel("Skip")
- .setStyle("SECONDARY")
+ .setStyle(ButtonStyle.Secondary)
.setCustomId("skip")
.setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
]
@@ -149,8 +153,8 @@
)
)
].concat([
- new MessageActionRow().addComponents([
- new MessageSelectMenu()
+ new ActionRowBuilder().addComponents([
+ new SelectMenuBuilder()
.setPlaceholder(`${object.name}`)
.setCustomId("rolemenu")
.setMinValues(object.min)