From a40ab35e3965e78edae32ce74467efc2bd62ed8a Mon Sep 17 00:00:00 2001 From: Martin Merfort <395822+mmerfort@users.noreply.github.com> Date: Sun, 14 Jul 2024 17:40:20 +0200 Subject: [PATCH] Fix deprecations --- .github/workflows/lint.yml | 2 +- src/commands/NFD.ts | 4 +- src/commands/RPG/Character.ts | 6 ++- src/commands/duel.ts | 4 +- src/commands/minesweeper.ts | 6 +-- src/commands/roleCommands/changecolor.ts | 4 +- src/commands/roleCommands/embedpls.ts | 2 +- src/commands/timeout.ts | 4 +- src/guards/RoleChecks.ts | 58 ++++++++++++------------ 9 files changed, 47 insertions(+), 43 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2d967d7..7c4b692 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -22,7 +22,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v1 with: - node-version: 16 + node-version: 22 - name: Install Node.js dependencies run: npm ci - name: Run linters diff --git a/src/commands/NFD.ts b/src/commands/NFD.ts index af4c1cb..6b19db5 100644 --- a/src/commands/NFD.ts +++ b/src/commands/NFD.ts @@ -1223,8 +1223,8 @@ class NFD { ) { const nfdName = nfd.name - const author = owner ? owner.nickname ?? owner.user.username : 'UNKNOWN' - const avatar = owner ? owner.user.avatarURL() ?? undefined : undefined + const author = owner ? (owner.nickname ?? owner.user.username) : 'UNKNOWN' + const avatar = owner ? (owner.user.avatarURL() ?? undefined) : undefined // Check for the existence of the image in the cache, if it doesn't exist, make it. diff --git a/src/commands/RPG/Character.ts b/src/commands/RPG/Character.ts index af489db..bb00460 100644 --- a/src/commands/RPG/Character.ts +++ b/src/commands/RPG/Character.ts @@ -23,7 +23,11 @@ export class Character { rng: () => number - public constructor(public user: User, public nickname: string, private seedPhrase?: string) { + public constructor( + public user: User, + public nickname: string, + private seedPhrase?: string + ) { // Maybe the screen name is better until folks can build their own character if (this.seedPhrase) { this.seed = cyrb53(this.seedPhrase) diff --git a/src/commands/duel.ts b/src/commands/duel.ts index a4df998..d03e92a 100644 --- a/src/commands/duel.ts +++ b/src/commands/duel.ts @@ -5,10 +5,10 @@ import { ButtonStyle, CommandInteraction, EmbedBuilder, - Formatters, GuildMember, Message, MessageActionRowComponentBuilder, + inlineCode, } from 'discord.js' import { Discord, Slash, SlashGroup } from 'discordx' import { injectable } from 'tsyringe' @@ -143,7 +143,7 @@ export class Duel { // Check if there is no current duel await collectionInteraction.followUp({ - content: `Someone beat you to the challenge! (or the duel expired... who knows!). You may issue a new challenge with ${Formatters.inlineCode( + content: `Someone beat you to the challenge! (or the duel expired... who knows!). You may issue a new challenge with ${inlineCode( '/duel' )}.`, ephemeral: true, diff --git a/src/commands/minesweeper.ts b/src/commands/minesweeper.ts index 0eb4d9c..476606e 100644 --- a/src/commands/minesweeper.ts +++ b/src/commands/minesweeper.ts @@ -1,4 +1,4 @@ -import { ApplicationCommandOptionType, CommandInteraction, Formatters } from 'discord.js' +import { ApplicationCommandOptionType, CommandInteraction, spoiler } from 'discord.js' import { Discord, SimpleCommand, @@ -116,13 +116,13 @@ class Board { const tile = this.neighbors[i] if (tile === -1) { - board += Formatters.spoiler(`:${this.randomBomb()}:`) + board += spoiler(`:${this.randomBomb()}:`) } else { if (tile === 0 && !startRevealed) { board += `:${Board.neighborCounts[tile]}:` startRevealed = true } else { - board += Formatters.spoiler(`:${Board.neighborCounts[tile]}:`) + board += spoiler(`:${Board.neighborCounts[tile]}:`) } } } diff --git a/src/commands/roleCommands/changecolor.ts b/src/commands/roleCommands/changecolor.ts index 09b0876..c65e7dd 100644 --- a/src/commands/roleCommands/changecolor.ts +++ b/src/commands/roleCommands/changecolor.ts @@ -11,7 +11,7 @@ import { import { ApplicationCommandOptionType, CommandInteraction, - Formatters, + italic, Guild, GuildMember, HexColorString, @@ -293,7 +293,7 @@ export class ColorRoles { const hexColor: HexColorString = color[0] !== '#' ? `#${color}` : (color as HexColorString) let favoriteString = ' ' if (isFavorite || hexColor === userOptions.favColor?.toUpperCase()) { - favoriteString += Formatters.italic('favorite') + ' ' + favoriteString += italic('favorite') + ' ' } await ColorRoles.setColor(hexColor, member, guild) diff --git a/src/commands/roleCommands/embedpls.ts b/src/commands/roleCommands/embedpls.ts index 3189319..b166fd0 100644 --- a/src/commands/roleCommands/embedpls.ts +++ b/src/commands/roleCommands/embedpls.ts @@ -1,5 +1,5 @@ import { Discord, SimpleCommand, SimpleCommandMessage, Slash, SlashOption } from 'discordx' -import { ApplicationCommandOptionType, CommandInteraction, GuildMember, GuildMemberRoleManager, User } from 'discord.js' +import { ApplicationCommandOptionType, CommandInteraction, GuildMember, GuildMemberRoleManager } from 'discord.js' import { memberIsSU } from '../../guards/RoleChecks.js' // Intentionally leaving out the slash command for this as it doesn't really make sense to diff --git a/src/commands/timeout.ts b/src/commands/timeout.ts index 5f775b2..b1ba551 100644 --- a/src/commands/timeout.ts +++ b/src/commands/timeout.ts @@ -4,7 +4,7 @@ import { ButtonBuilder, ButtonStyle, CommandInteraction, - Formatters, + quote, Guild, GuildMember, GuildMemberRoleManager, @@ -67,7 +67,7 @@ abstract class Timeout { async sudoku(member: GuildMember | null, message?: string): Promise { const time = this.sudokuDuration() await member?.timeout(time * 1000, "Sudoku'd").catch(console.error) - const msg = message && message.length < 150 ? `\n${Formatters.quote(message)}` : '' + const msg = message && message.length < 150 ? `\n${quote(message)}` : '' // If the Sudoku-ee is a Super User send them a DM with a button to remove the timeout if (memberIsSU(member)) { diff --git a/src/guards/RoleChecks.ts b/src/guards/RoleChecks.ts index 027b3a5..07fa3b2 100644 --- a/src/guards/RoleChecks.ts +++ b/src/guards/RoleChecks.ts @@ -8,7 +8,7 @@ import { GuildMember, Message, MessageReaction, - SelectMenuInteraction, + StringSelectMenuInteraction, VoiceState, } from 'discord.js' @@ -35,7 +35,7 @@ export const NotBot: GuardFunction< | ArgsOf<'messageCreate' | 'messageReactionAdd' | 'voiceStateUpdate'> | CommandInteraction | ContextMenuCommandInteraction - | SelectMenuInteraction + | StringSelectMenuInteraction | ButtonInteraction | SimpleCommandMessage > = async (arg, _, next) => { @@ -44,19 +44,19 @@ export const NotBot: GuardFunction< argObj instanceof CommandInteraction ? argObj.user : argObj instanceof MessageReaction - ? argObj.message.author - : argObj instanceof VoiceState - ? argObj.member?.user - : argObj instanceof Message - ? argObj.author - : argObj instanceof SimpleCommandMessage - ? argObj.message.author - : argObj instanceof CommandInteraction || - argObj instanceof ContextMenuCommandInteraction || - argObj instanceof SelectMenuInteraction || - argObj instanceof ButtonInteraction - ? argObj.member?.user - : argObj?.message?.author + ? argObj.message.author + : argObj instanceof VoiceState + ? argObj.member?.user + : argObj instanceof Message + ? argObj.author + : argObj instanceof SimpleCommandMessage + ? argObj.message.author + : argObj instanceof CommandInteraction || + argObj instanceof ContextMenuCommandInteraction || + argObj instanceof StringSelectMenuInteraction || + argObj instanceof ButtonInteraction + ? argObj.member?.user + : argObj?.message?.author if (!user?.bot) { await next() } @@ -66,7 +66,7 @@ export const IsSuperUser: GuardFunction< | ArgsOf<'messageCreate' | 'messageReactionAdd' | 'voiceStateUpdate'> | CommandInteraction | ContextMenuCommandInteraction - | SelectMenuInteraction + | StringSelectMenuInteraction | ButtonInteraction | SimpleCommandMessage > = async (arg, _, next) => { @@ -75,19 +75,19 @@ export const IsSuperUser: GuardFunction< argObj instanceof CommandInteraction ? argObj.member : argObj instanceof MessageReaction - ? argObj.message.member - : argObj instanceof VoiceState - ? argObj.member - : argObj instanceof Message - ? argObj.member - : argObj instanceof SimpleCommandMessage - ? argObj.message.member - : argObj instanceof CommandInteraction || - argObj instanceof ContextMenuCommandInteraction || - argObj instanceof SelectMenuInteraction || - argObj instanceof ButtonInteraction - ? argObj.member - : argObj?.message?.member + ? argObj.message.member + : argObj instanceof VoiceState + ? argObj.member + : argObj instanceof Message + ? argObj.member + : argObj instanceof SimpleCommandMessage + ? argObj.message.member + : argObj instanceof CommandInteraction || + argObj instanceof ContextMenuCommandInteraction || + argObj instanceof StringSelectMenuInteraction || + argObj instanceof ButtonInteraction + ? argObj.member + : argObj?.message?.member if (memberIsSU(member)) { await next() }