diff --git a/commands/admin-standup.js b/commands/admin-standup.js index bf58da97..31540dba 100644 --- a/commands/admin-standup.js +++ b/commands/admin-standup.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require("@discordjs/builders"); -const { MessageEmbed, MessageButton, Permissions } = require("discord.js"); +const { EmbedBuilder, ButtonBuilder, Permissions } = require("discord.js"); const paginationEmbed = require("discordjs-button-pagination"); module.exports = { @@ -104,7 +104,7 @@ module.exports = { if (notDone.length == 0) { standupEmbeded.forEach((el) => { embedList.push( - new MessageEmbed() + new EmbedBuilder() .setTitle("Standups (" + role.name + ")") .setDescription( el + "\n\n" + "_Everyone has done their standup_\n", @@ -114,7 +114,7 @@ module.exports = { } else { standupEmbeded.forEach((el) => { embedList.push( - new MessageEmbed() + new EmbedBuilder() .setTitle("Standups (" + role.name + ")") .setDescription( el + @@ -127,7 +127,7 @@ module.exports = { } if (thisTeamStandups.length == 0) { - const embed = new MessageEmbed() + const embed = new EmbedBuilder() .setTitle("Standups (" + role.name + ")") .setDescription( "No standups recorded\n\n" + @@ -138,11 +138,11 @@ module.exports = { } const buttonList = [ - new MessageButton() + new ButtonBuilder() .setCustomId("previousbtn") .setLabel("Previous") .setStyle("DANGER"), - new MessageButton().setCustomId("nextbtn").setLabel("Next").setStyle("SUCCESS"), + new ButtonBuilder().setCustomId("nextbtn").setLabel("Next").setStyle("SUCCESS"), ]; paginationEmbed(interaction, embedList, buttonList); diff --git a/commands/anonymouspost.js b/commands/anonymouspost.js index 1813ddb9..7f62838e 100644 --- a/commands/anonymouspost.js +++ b/commands/anonymouspost.js @@ -2,7 +2,7 @@ const { SlashCommandBuilder } = require("@discordjs/builders"); const { allowedChannels } = require("../config/anon_channel.json"); const paginationEmbed = require("discordjs-button-pagination"); const fs = require("fs"); -const { Util, MessageEmbed, MessageButton, Permissions } = require("discord.js"); +const { Util, EmbedBuilder, ButtonBuilder, Permissions } = require("discord.js"); module.exports = { data: new SlashCommandBuilder() .setName("anonymouspost") @@ -223,7 +223,7 @@ module.exports = { } else if (interaction.options.getSubcommand() === "whitelist") { // No allowed roles if (allowedChannels.length == 0) { - const embed = new MessageEmbed() + const embed = new EmbedBuilder() .setTitle("Allowed Channels") .setDescription("No allowed channels"); return await interaction.reply({ embeds: [embed] }); @@ -239,7 +239,7 @@ module.exports = { } if (channels.length == 0) { - const embed = new MessageEmbed() + const embed = new EmbedBuilder() .setTitle("Allowed Channels") .setDescription("No allowed channels"); return await interaction.reply({ embeds: [embed] }); @@ -250,18 +250,18 @@ module.exports = { const embedList = []; for (let i = 0; i < channels.length; i += channelsPerPage) { embedList.push( - new MessageEmbed() + new EmbedBuilder() .setTitle("Allowed Channels") .setDescription(channels.slice(i, i + channelsPerPage).join("\n")), ); } const buttonList = [ - new MessageButton() + new ButtonBuilder() .setCustomId("previousbtn") .setLabel("Previous") .setStyle("DANGER"), - new MessageButton().setCustomId("nextbtn").setLabel("Next").setStyle("SUCCESS"), + new ButtonBuilder().setCustomId("nextbtn").setLabel("Next").setStyle("SUCCESS"), ]; paginationEmbed(interaction, embedList, buttonList); diff --git a/commands/coinFlip.js b/commands/coinFlip.js index d0b2525a..f4999358 100644 --- a/commands/coinFlip.js +++ b/commands/coinFlip.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require("@discordjs/builders"); -const { MessageEmbed } = require("discord.js"); +const { EmbedBuilder } = require("discord.js"); module.exports = { data: new SlashCommandBuilder().setName("coinflip").setDescription("Tosses a coin 💰"), @@ -13,7 +13,7 @@ module.exports = { : 'http://assets.stickpng.com/thumbs/5a521f522f93c7a8d5137fc7.png'; */ const img = coinNum === 0 ? "attachment://heads.png" : "attachment://tails.png"; - const embed = new MessageEmbed().setTitle(`it's ${coin}!`).setImage(img); + const embed = new EmbedBuilder().setTitle(`it's ${coin}!`).setImage(img); if (coinNum == 0) { return await interaction.reply({ embeds: [embed], diff --git a/commands/faq.js b/commands/faq.js index b7f08e57..e62da137 100644 --- a/commands/faq.js +++ b/commands/faq.js @@ -1,6 +1,6 @@ // @ts-check const { SlashCommandBuilder, SlashCommandSubcommandBuilder } = require("@discordjs/builders"); -const { MessageEmbed } = require("discord.js"); +const { EmbedBuilder } = require("discord.js"); const { DiscordScroll } = require("../lib/discordscroll/scroller"); // //////////////////////////////////////////// @@ -116,7 +116,7 @@ async function handleFAQGetAll(interaction, faqStorage) { const answers = []; let currentPage = 0; for (const row of rows) { - const newPage = new MessageEmbed({ + const newPage = new EmbedBuilder({ title: `FAQS for the tag: ${tag}`, color: 0xf1c40f, timestamp: new Date().getTime(), diff --git a/commands/handbook.js b/commands/handbook.js index 40b4e22c..78ac9387 100644 --- a/commands/handbook.js +++ b/commands/handbook.js @@ -1,7 +1,7 @@ const axios = require("axios"); const textVersion = require("textversionjs"); const { SlashCommandBuilder } = require("@discordjs/builders"); -const { MessageEmbed } = require("discord.js"); +const { EmbedBuilder } = require("discord.js"); const { apiURL, handbookURL } = require("../config/handbook.json"); module.exports = { @@ -55,7 +55,7 @@ module.exports = { terms, } = data; - const courseInfo = new MessageEmbed() + const courseInfo = new EmbedBuilder() .setTitle(title) .setURL(`${handbookURL}/${code}`) .setColor(0x3a76f8) diff --git a/commands/help.js b/commands/help.js index 85fec410..ebc890c3 100644 --- a/commands/help.js +++ b/commands/help.js @@ -1,6 +1,6 @@ const help = require("../config/help.json"); const { SlashCommandBuilder } = require("@discordjs/builders"); -const { MessageEmbed, MessageActionRow, MessageButton } = require("discord.js"); +const { EmbedBuilder, ActionRowBuilder, ButtonBuilder } = require("discord.js"); // Fetches commands from the help data const commands = help.commands; @@ -9,13 +9,13 @@ const commands = help.commands; const prevId = "helpPrevButtonId"; const nextId = "helpNextButtonId"; -const prevButton = new MessageButton({ +const prevButton = new ButtonBuilder({ style: "SECONDARY", label: "Previous", emoji: "⬅️", customId: prevId, }); -const nextButton = new MessageButton({ +const nextButton = new ButtonBuilder({ style: "SECONDARY", label: "Next", emoji: "➡️", @@ -27,13 +27,13 @@ const PAGE_SIZE = 10; /** * Creates an embed with commands starting from an index. * @param {number} start The index to start from. - * @returns {MessageEmbed} + * @returns {EmbedBuilder} */ const generateEmbed = (start) => { const current = commands.slice(start, start + PAGE_SIZE); const pageNum = Math.floor(start / PAGE_SIZE) + 1; - return new MessageEmbed({ + return new EmbedBuilder({ title: `Help Command - Page ${pageNum}`, color: 0x3a76f8, author: { @@ -86,7 +86,7 @@ module.exports = { await interaction.reply({ embeds: [helpEmbed], components: [ - new MessageActionRow({ + new ActionRowBuilder({ components: [ // previous button if it isn't the start ...(currentIndex ? [prevButton] : []), @@ -118,7 +118,7 @@ module.exports = { await i.update({ embeds: [generateEmbed(currentIndex)], components: [ - new MessageActionRow({ + new ActionRowBuilder({ components: [ // previous button if it isn't the start ...(currentIndex ? [prevButton] : []), diff --git a/commands/joke.js b/commands/joke.js index 76f6d5af..d7cbc21f 100644 --- a/commands/joke.js +++ b/commands/joke.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require("@discordjs/builders"); -const { MessageEmbed } = require("discord.js"); +const { EmbedBuilder } = require("discord.js"); const axios = require("axios").default; module.exports = { @@ -9,7 +9,7 @@ module.exports = { .get("https://official-joke-api.appspot.com/random_joke") .then((res) => { // console.log(res.data); - const embed = new MessageEmbed() + const embed = new EmbedBuilder() .setTitle(res.data.setup) .setDescription(res.data.punchline); diff --git a/commands/meetingtools.js b/commands/meetingtools.js index a3630885..8a062c7c 100644 --- a/commands/meetingtools.js +++ b/commands/meetingtools.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require("@discordjs/builders"); -const { MessageEmbed } = require("discord.js"); +const { EmbedBuilder } = require("discord.js"); // Tools to help manage meetings @@ -153,7 +153,7 @@ module.exports = { }); } - const embed = new MessageEmbed() + const embed = new EmbedBuilder() .setTitle(command) .setColor("#0099ff") .setDescription(ret_val); diff --git a/commands/reactforrole.js b/commands/reactforrole.js index ed66b82c..e6f52bb6 100644 --- a/commands/reactforrole.js +++ b/commands/reactforrole.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require("@discordjs/builders"); -const { Permissions, MessageEmbed } = require("discord.js"); +const { Permissions, EmbedBuilder } = require("discord.js"); module.exports = { data: new SlashCommandBuilder() @@ -144,7 +144,7 @@ module.exports = { // Notify user that they used the command const botName = sentMessage.author.username; - const notification = new MessageEmbed() + const notification = new EmbedBuilder() .setColor("#7cd699") .setTitle("React For Role Command Used!") .setAuthor(botName, "https://avatars.githubusercontent.com/u/164179?s=200&v=4") diff --git a/commands/schedulepost.js b/commands/schedulepost.js index 9b88cb9c..9d438542 100644 --- a/commands/schedulepost.js +++ b/commands/schedulepost.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require("@discordjs/builders"); -const { MessageEmbed, Permissions } = require("discord.js"); +const { EmbedBuilder, Permissions } = require("discord.js"); module.exports = { data: new SlashCommandBuilder() @@ -164,7 +164,7 @@ async function create_scheduled_post(interaction, msg_id, channel, datetime) { const send_in = ("in " + dDisplay + hDisplay + mDisplay + sDisplay).replace(/,\s*$/, ""); // Create message preview - const preview = new MessageEmbed() + const preview = new EmbedBuilder() .setColor("#C492B1") .setTitle("Message Preview") .setDescription( diff --git a/commands/vote.js b/commands/vote.js index b513ac61..595d271f 100644 --- a/commands/vote.js +++ b/commands/vote.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require("@discordjs/builders"); -const { MessageEmbed } = require("discord.js"); +const { EmbedBuilder } = require("discord.js"); let { data } = require("../config/votes.json"); const fs = require("fs"); @@ -44,7 +44,7 @@ module.exports = { votestring = votestring + ", vote by " + voteauthorname; // Generating the embed - const embed = new MessageEmbed().setTitle(votestring); + const embed = new EmbedBuilder().setTitle(votestring); const message = await interaction.reply({ embeds: [embed], fetchReply: true, @@ -71,7 +71,7 @@ module.exports = { const found = data.find((element) => element.channelid == channelid); if (found == undefined) { - const embed = new MessageEmbed().setTitle("0 votes found on this channel"); + const embed = new EmbedBuilder().setTitle("0 votes found on this channel"); await interaction.reply({ embeds: [embed], fetchReply: true }); return; } else { @@ -99,7 +99,7 @@ module.exports = { }); } }); - const embed = new MessageEmbed() + const embed = new EmbedBuilder() .setTitle(found.string) .addFields(responses); @@ -127,7 +127,7 @@ module.exports = { const found = data.find((element) => element.channelid == channelid); if (found == undefined) { - const embed = new MessageEmbed().setTitle("0 votes found on this channel"); + const embed = new EmbedBuilder().setTitle("0 votes found on this channel"); await interaction.reply({ embeds: [embed], fetchReply: true }); return; } else { @@ -156,7 +156,7 @@ module.exports = { } responses.push(temp); }); - const embed = new MessageEmbed() + const embed = new EmbedBuilder() .setTitle(found.string) .addFields(responses); diff --git a/commands/xkcd.js b/commands/xkcd.js index bdc918da..de9d62d2 100644 --- a/commands/xkcd.js +++ b/commands/xkcd.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require("@discordjs/builders"); -const { MessageEmbed } = require("discord.js"); +const { EmbedBuilder } = require("discord.js"); module.exports = { data: new SlashCommandBuilder() @@ -34,7 +34,7 @@ module.exports = { ephemeral: true, }); } else { - const embed = new MessageEmbed() + const embed = new EmbedBuilder() .setTitle(response.safe_title) .setImage(response.img); return await interaction.reply({ embeds: [embed] }); @@ -51,7 +51,7 @@ module.exports = { ephemeral: true, }); } else { - const embed = new MessageEmbed() + const embed = new EmbedBuilder() .setTitle(response.safe_title) .setImage(response.img); return await interaction.reply({ embeds: [embed] }); @@ -66,7 +66,7 @@ module.exports = { ephemeral: true, }); } else { - const embed = new MessageEmbed() + const embed = new EmbedBuilder() .setTitle(response.safe_title) .setImage(response.img); return await interaction.reply({ embeds: [embed] }); diff --git a/events/givereactrole.js b/events/givereactrole.js index a184a4ef..35240b6d 100644 --- a/events/givereactrole.js +++ b/events/givereactrole.js @@ -1,4 +1,4 @@ -const { MessageEmbed } = require("discord.js"); +const { EmbedBuilder } = require("discord.js"); module.exports = { name: "messageReactionAdd", @@ -43,7 +43,7 @@ module.exports = { const botName = await reaction.message.author.username; // Notify user that role was not assigned - const notification = new MessageEmbed() + const notification = new EmbedBuilder() .setColor("#7cd699") .setTitle("Role could not be assigned") .setAuthor( @@ -73,7 +73,7 @@ async function giveRole(reaction, user, roleId) { const botName = await reaction.message.author.username; // Notify user role was successfully added - const notification = new MessageEmbed() + const notification = new EmbedBuilder() .setColor("#7cd699") .setTitle("Roles updated!") .setAuthor(botName, "https://avatars.githubusercontent.com/u/164179?s=200&v=4") diff --git a/events/lunch_buddy.js b/events/lunch_buddy.js index 1063a4bd..84b3227e 100644 --- a/events/lunch_buddy.js +++ b/events/lunch_buddy.js @@ -1,4 +1,4 @@ -const { MessageEmbed, MessageButton, MessageActionRow } = require("discord.js"); +const { EmbedBuilder, ButtonBuilder, ActionRowBuilder } = require("discord.js"); const cron = require("node-cron"); const lunchBuddyLocations = require("../data/lunch_buddy_locations"); const config = require("../config/lunch_buddy.json"); @@ -31,7 +31,7 @@ const generateAreasEmbed = (areaVotes) => { (element) => `${element.value}: ${areaVotes ? areaVotes[element.value].length : 0}`, ); areas.push(`Any: ${areaVotes ? areaVotes["Any"].length : 0}`); - return new MessageEmbed() + return new EmbedBuilder() .setTitle("Meetup Area Selection") .setColor(0x0099ff) .setDescription("Please select an option below to vote for that area!") @@ -53,7 +53,7 @@ const generateLocationsEmbed = (area, votes) => { (element) => `${element.name}: ${votes ? votes[element.name].length : 0}`, ); locations.push(`Any: ${votes ? votes["Any"].length : 0}`); - return new MessageEmbed() + return new EmbedBuilder() .setTitle(`Meetup Location Selection - ${area}`) .setColor(0x0099ff) .setDescription("Please select an option below to vote for that location!") @@ -73,21 +73,21 @@ const areasList = lunchBuddyLocations.locations.map((element) => element.value); areasList.push("Any"); const areasButtons = lunchBuddyLocations.locations.map( (element) => - new MessageButton({ + new ButtonBuilder({ style: "PRIMARY", label: element.value, customId: `${element.value}${areaButtonCustomId}`, }), ); areasButtons.push( - new MessageButton({ + new ButtonBuilder({ style: "PRIMARY", label: "Surprise Me!", customId: `Any${areaButtonCustomId}`, }), ); areasButtons.push( - new MessageButton({ + new ButtonBuilder({ style: "DANGER", label: "Remove Vote", customId: `Remove${areaButtonCustomId}`, @@ -101,7 +101,7 @@ areasButtonsIds.push(`Remove${areaButtonCustomId}`); const areasActionRows = []; for (let i = 0; i < areasButtons.length; i += maxRowButtons) { areasActionRows.push( - new MessageActionRow({ components: areasButtons.slice(i, i + maxRowButtons) }), + new ActionRowBuilder({ components: areasButtons.slice(i, i + maxRowButtons) }), ); } @@ -253,21 +253,21 @@ module.exports = { // client.channels.fetch(voteOriginId).then(async (voteChannel) => { const locationsButtons = locationData.sub.map( (element) => - new MessageButton({ + new ButtonBuilder({ style: "PRIMARY", label: element.name, customId: `${element.name}${locationButtonCustomId}`, }), ); locationsButtons.push( - new MessageButton({ + new ButtonBuilder({ style: "PRIMARY", label: "Surprise Me!", customId: `Any${locationButtonCustomId}`, }), ); locationsButtons.push( - new MessageButton({ + new ButtonBuilder({ style: "DANGER", label: "Remove Vote", customId: `Remove${locationButtonCustomId}`, @@ -281,7 +281,7 @@ module.exports = { const locationsActionRows = []; for (let i = 0; i < locationsButtons.length; i += maxRowButtons) { locationsActionRows.push( - new MessageActionRow({ + new ActionRowBuilder({ components: locationsButtons.slice(i, i + maxRowButtons), }), ); diff --git a/events/removereactrole.js b/events/removereactrole.js index 41076ca0..2f882bb4 100644 --- a/events/removereactrole.js +++ b/events/removereactrole.js @@ -1,4 +1,4 @@ -const { MessageEmbed } = require("discord.js"); +const { EmbedBuilder } = require("discord.js"); module.exports = { name: "messageReactionRemove", @@ -57,7 +57,7 @@ async function removeRole(reaction, user, roleId) { const botName = await reaction.message.author.username; // Notify user role was successfully removed - const notification = new MessageEmbed() + const notification = new EmbedBuilder() .setColor("#7cd699") .setTitle("Roles updated!") .setAuthor(botName, "https://avatars.githubusercontent.com/u/164179?s=200&v=4") diff --git a/events/sendscheduled.js b/events/sendscheduled.js index c393b5fe..bfb37903 100644 --- a/events/sendscheduled.js +++ b/events/sendscheduled.js @@ -1,4 +1,4 @@ -const { MessageAttachment } = require("discord.js"); +const { AttachmentBuilder } = require("discord.js"); // Checks database every minute to see if there is a message to be sent @@ -29,7 +29,7 @@ module.exports = { // Retrieve attachments if applicable const attachment_list = []; send_msg.attachments.forEach((attachment) => { - attachment_list.push(new MessageAttachment(attachment.proxyURL)); + attachment_list.push(new AttachmentBuilder(attachment.proxyURL)); }); // Retrieve message content diff --git a/events/sendscheduled_reminders.js b/events/sendscheduled_reminders.js index 2578378f..b7a919c0 100644 --- a/events/sendscheduled_reminders.js +++ b/events/sendscheduled_reminders.js @@ -1,4 +1,4 @@ -const { MessageEmbed } = require("discord.js"); +const { EmbedBuilder } = require("discord.js"); // Checks database every minute to check if a reminder needs // to be sent to the users who reacted with an alarm clock emoji in the original @@ -32,7 +32,7 @@ module.exports = { users_reacted.forEach((user) => { if (!user.bot) { - const reminder_msg = new MessageEmbed() + const reminder_msg = new EmbedBuilder() .setColor("#C492B1") .setTitle("Reminder") .setDescription( diff --git a/index.js b/index.js index aee5fe3e..3f0dbeca 100644 --- a/index.js +++ b/index.js @@ -1,16 +1,16 @@ const fs = require("fs"); -const { Client, Collection, Intents } = require("discord.js"); +const { Client, Collection, GatewayIntentBits } = require("discord.js"); require("dotenv").config(); // Create a new client instance const client = new Client({ intents: [ - Intents.FLAGS.GUILDS, - Intents.FLAGS.GUILD_MEMBERS, - Intents.FLAGS.GUILD_MESSAGES, - Intents.FLAGS.GUILD_MESSAGE_REACTIONS, - Intents.FLAGS.GUILD_VOICE_STATES, - Intents.FLAGS.GUILD_PRESENCES, + GatewayIntentBits.Guilds, + GatewayIntentBits.GuildMembers, + GatewayIntentBits.GuildMessages, + GatewayIntentBits.GuildMessageReactions, + GatewayIntentBits.GuildVoiceStates, + GatewayIntentBits.GuildPresences, ], partials: ["MESSAGE", "CHANNEL", "REACTION", "GUILD_MEMBER", "USER"], }); diff --git a/lib/carrotboard/index.js b/lib/carrotboard/index.js index d68d1452..4eb232db 100644 --- a/lib/carrotboard/index.js +++ b/lib/carrotboard/index.js @@ -1,7 +1,7 @@ // @ts-check /* eslint-disable */ // const { Embed } = require("@discordjs/builders"); -const { MessageEmbed } = require("discord.js"); +const { EmbedBuilder } = require("discord.js"); const { DBcarrotboard } = require("../database/dbcarrotboard"); const fs = require("fs"); const YAML = require("yaml"); @@ -50,7 +50,7 @@ class CarrotboardStorage { } // create the embed - /** @type {MessageEmbedOptions} */ + /** @type {EmbedBuilderOptions} */ const embedOptions = { description: `**${messageContent}**`, color: message.member.displayHexColor, @@ -74,7 +74,7 @@ class CarrotboardStorage { } // send it - const embed = new MessageEmbed(embedOptions); + const embed = new EmbedBuilder(embedOptions); await alertChannel.send({ embeds: [embed] }); } @@ -137,7 +137,7 @@ class CarrotboardStorage { // check if new page need to be made if ((entryIndex - 1) % this.rowsPerPage == 0) { - const newPage = new MessageEmbed({ + const newPage = new EmbedBuilder({ title: "Top carroted messages :trophy: :medal:", color: 0xf1c40f, timestamp: new Date().getTime(), @@ -203,7 +203,7 @@ class CarrotboardStorage { // there werent any results, add the empty embed if (embedPages.length == 0) { - const sadEmbed = new MessageEmbed({ + const sadEmbed = new EmbedBuilder({ title: "There are no Carroted Messages :( :sob: :smiling_face_with_tear:", description: " ", }); diff --git a/lib/discordscroll/scroller.js b/lib/discordscroll/scroller.js index 5dd39529..fd70c25d 100644 --- a/lib/discordscroll/scroller.js +++ b/lib/discordscroll/scroller.js @@ -1,4 +1,4 @@ -const { MessageEmbed, CommandInteraction, MessageButton, MessageActionRow } = require("discord.js"); +const { EmbedBuilder, CommandInteraction, ButtonBuilder, ActionRowBuilder } = require("discord.js"); class DiscordScroll { /** @protected @type {Boolean} */ @@ -12,21 +12,21 @@ class DiscordScroll { _collector = null; /** @protected */ _buttons = { - left: new MessageButton().setCustomId("scrollLeft").setEmoji("⬅️").setStyle("SECONDARY"), - right: new MessageButton().setCustomId("scrollRight").setEmoji("➡️").setStyle("SECONDARY"), - delete: new MessageButton().setCustomId("scrollDelete").setEmoji("🚮").setStyle("DANGER"), + left: new ButtonBuilder().setCustomId("scrollLeft").setEmoji("⬅️").setStyle("SECONDARY"), + right: new ButtonBuilder().setCustomId("scrollRight").setEmoji("➡️").setStyle("SECONDARY"), + delete: new ButtonBuilder().setCustomId("scrollDelete").setEmoji("🚮").setStyle("DANGER"), }; - /** @protected @type {?MessageEmbed} */ + /** @protected @type {?EmbedBuilder} */ _embed = null; /** @protected @type {Number} */ _pagenum = 0; - /** @protected @type {MessageEmbed[]} */ + /** @protected @type {EmbedBuilder[]} */ _pages = []; /** * Constructor for the Scroller - * @param {MessageEmbed[]} pages + * @param {EmbedBuilder[]} pages */ constructor(pages) { this.pages = pages; @@ -35,14 +35,14 @@ class DiscordScroll { /** * The pages of the Scroller. - * @type {MessageEmbed[]} + * @type {EmbedBuilder[]} */ get pages() { return this._pages; } /** - * @param {MessageEmbed[]} value The array of Embeds + * @param {EmbedBuilder[]} value The array of Embeds */ set pages(value) { // type check the array @@ -50,8 +50,8 @@ class DiscordScroll { throw new TypeError("DiscordScroll.pages expected an array."); } else if (value.length == 0) { throw new TypeError("DiscordScroll.pages expected at least one element in the array."); - } else if (!value.every((e) => e instanceof MessageEmbed)) { - throw new TypeError("DiscordScroll.pages expected an array of MessageEmbeds."); + } else if (!value.every((e) => e instanceof EmbedBuilder)) { + throw new TypeError("DiscordScroll.pages expected an array of EmbedBuilders."); } this._pages = value; @@ -59,7 +59,7 @@ class DiscordScroll { /** * The current shown Embed. - * @type {MessageEmbed} + * @type {EmbedBuilder} * @readonly */ get embed() { @@ -68,7 +68,7 @@ class DiscordScroll { /** * The current page. - * @type {MessageEmbed} + * @type {EmbedBuilder} * @readonly */ get currentPage() { @@ -127,7 +127,7 @@ class DiscordScroll { * Gets the Button Row, updating the button status if needed. * @protected * @readonly - * @returns {MessageActionRow} + * @returns {ActionRowBuilder} */ get _getButtonRow() { if (this._pagenum === 0) { @@ -142,7 +142,7 @@ class DiscordScroll { this._buttons.right.setDisabled(false); } - return new MessageActionRow().addComponents( + return new ActionRowBuilder().addComponents( this._buttons.left, this._buttons.right, this._buttons.delete, diff --git a/lib/tictactoe/tttHelper.js b/lib/tictactoe/tttHelper.js index cd365565..31eafdcf 100644 --- a/lib/tictactoe/tttHelper.js +++ b/lib/tictactoe/tttHelper.js @@ -1,4 +1,4 @@ -const { MessageActionRow, MessageButton } = require("discord.js"); +const { ActionRowBuilder, ButtonBuilder } = require("discord.js"); const { game } = require("./tttGame"); const maxNumGames = 1000; @@ -23,13 +23,13 @@ function gameToButtons(gameObj, gameId) { label = gameObj.board[i][j] ? "O" : "X"; style = gameObj.board[i][j] ? "PRIMARY" : "DANGER"; } - rowButtons[j] = new MessageButton() + rowButtons[j] = new ButtonBuilder() .setCustomId(`${gameId}:${i}:${j}`) .setLabel(label) .setStyle(style) .setDisabled(disableButton); } - messageRows[i] = new MessageActionRow().addComponents(rowButtons); + messageRows[i] = new ActionRowBuilder().addComponents(rowButtons); } return messageRows; }