mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-11 13:56:15 +00:00
fix(bots/discord): replace use of deprecated options.ephemeral in replies
This commit is contained in:
@@ -2,7 +2,7 @@ import { unlinkSync, writeFileSync } from 'fs'
|
|||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { inspect } from 'util'
|
import { inspect } from 'util'
|
||||||
import { createContext, runInContext } from 'vm'
|
import { createContext, runInContext } from 'vm'
|
||||||
import { ApplicationCommandOptionType } from 'discord.js'
|
import { ApplicationCommandOptionType, MessageFlags } from 'discord.js'
|
||||||
|
|
||||||
import { AdminCommand } from '$/classes/Command'
|
import { AdminCommand } from '$/classes/Command'
|
||||||
import { createSuccessEmbed } from '$/utils/discord/embeds'
|
import { createSuccessEmbed } from '$/utils/discord/embeds'
|
||||||
@@ -85,8 +85,8 @@ export default new AdminCommand({
|
|||||||
})
|
})
|
||||||
|
|
||||||
await trigger.reply({
|
await trigger.reply({
|
||||||
ephemeral: true,
|
|
||||||
embeds: [embed],
|
embeds: [embed],
|
||||||
|
flags: MessageFlags.Ephemeral,
|
||||||
files,
|
files,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { AdminCommand } from '$/classes/Command'
|
import { AdminCommand } from '$/classes/Command'
|
||||||
|
import { type CommandInteraction, MessageFlags } from 'discord.js'
|
||||||
|
|
||||||
export default new AdminCommand({
|
export default new AdminCommand({
|
||||||
name: 'reload',
|
name: 'reload',
|
||||||
@@ -10,7 +11,7 @@ export default new AdminCommand({
|
|||||||
logger.debug('Invalidating previous config...')
|
logger.debug('Invalidating previous config...')
|
||||||
context.config.invalidate()
|
context.config.invalidate()
|
||||||
|
|
||||||
if ('deferReply' in trigger) await trigger.deferReply({ ephemeral: true })
|
if ((trigger as CommandInteraction).deferReply) await trigger.deferReply({ flags: MessageFlags.Ephemeral })
|
||||||
|
|
||||||
logger.info('Reinitializing API client to reload configuration...')
|
logger.info('Reinitializing API client to reload configuration...')
|
||||||
await api.client.ws.setOptions(
|
await api.client.ws.setOptions(
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { AdminCommand } from '$/classes/Command'
|
import { AdminCommand } from '$/classes/Command'
|
||||||
|
import { MessageFlags } from 'discord.js'
|
||||||
|
|
||||||
export default new AdminCommand({
|
export default new AdminCommand({
|
||||||
name: 'stop',
|
name: 'stop',
|
||||||
@@ -9,7 +10,7 @@ export default new AdminCommand({
|
|||||||
logger.fatal('Stopping bot...')
|
logger.fatal('Stopping bot...')
|
||||||
trigger.reply({
|
trigger.reply({
|
||||||
content: 'Stopping... (I will go offline once done)',
|
content: 'Stopping... (I will go offline once done)',
|
||||||
ephemeral: true,
|
flags: MessageFlags.Ephemeral,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!api.client.disconnected) api.client.disconnect()
|
if (!api.client.disconnected) api.client.disconnect()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { EmbedBuilder } from 'discord.js'
|
import { EmbedBuilder, MessageFlags } from 'discord.js'
|
||||||
|
|
||||||
import Command from '$/classes/Command'
|
import Command from '$/classes/Command'
|
||||||
import { applyCommonEmbedStyles } from '$/utils/discord/embeds'
|
import { applyCommonEmbedStyles } from '$/utils/discord/embeds'
|
||||||
@@ -18,6 +18,7 @@ export default new Command({
|
|||||||
const reply = await trigger
|
const reply = await trigger
|
||||||
.reply({
|
.reply({
|
||||||
embeds: [embed.toJSON()],
|
embeds: [embed.toJSON()],
|
||||||
|
flags: MessageFlags.Ephemeral,
|
||||||
})
|
})
|
||||||
.then(it => it.fetch())
|
.then(it => it.fetch())
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import CommandError, { CommandErrorType } from '$/classes/CommandError'
|
import CommandError, { CommandErrorType } from '$/classes/CommandError'
|
||||||
import { ApplicationCommandOptionType, Message } from 'discord.js'
|
import { ApplicationCommandOptionType, Message, MessageFlags } from 'discord.js'
|
||||||
import { ModerationCommand } from '../../classes/Command'
|
import { ModerationCommand } from '../../classes/Command'
|
||||||
|
|
||||||
export default new ModerationCommand({
|
export default new ModerationCommand({
|
||||||
@@ -40,7 +40,7 @@ export default new ModerationCommand({
|
|||||||
|
|
||||||
await trigger.reply({
|
await trigger.reply({
|
||||||
content: 'OK!',
|
content: 'OK!',
|
||||||
ephemeral: true,
|
flags: MessageFlags.Ephemeral,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { ModerationCommand } from '$/classes/Command'
|
import { ModerationCommand } from '$/classes/Command'
|
||||||
import { createSuccessEmbed } from '$/utils/discord/embeds'
|
import { createSuccessEmbed } from '$/utils/discord/embeds'
|
||||||
import { cureNickname } from '$/utils/discord/moderation'
|
import { cureNickname } from '$/utils/discord/moderation'
|
||||||
|
import { MessageFlags } from 'discord.js'
|
||||||
|
|
||||||
export default new ModerationCommand({
|
export default new ModerationCommand({
|
||||||
name: 'cure',
|
name: 'cure',
|
||||||
@@ -18,7 +19,7 @@ export default new ModerationCommand({
|
|||||||
await cureNickname(member)
|
await cureNickname(member)
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
embeds: [createSuccessEmbed(null, `Cured nickname for ${member.toString()}`)],
|
embeds: [createSuccessEmbed(null, `Cured nickname for ${member.toString()}`)],
|
||||||
ephemeral: true,
|
flags: MessageFlags.Ephemeral,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import Command from '$/classes/Command'
|
|||||||
import CommandError, { CommandErrorType } from '$/classes/CommandError'
|
import CommandError, { CommandErrorType } from '$/classes/CommandError'
|
||||||
import { createSuccessEmbed } from '$/utils/discord/embeds'
|
import { createSuccessEmbed } from '$/utils/discord/embeds'
|
||||||
import type { ConfigMessageScanResponseLabelConfig } from 'config.schema'
|
import type { ConfigMessageScanResponseLabelConfig } from 'config.schema'
|
||||||
import type { FetchMessageOptions, MessageResolvable } from 'discord.js'
|
import { type FetchMessageOptions, MessageFlags, type MessageResolvable } from 'discord.js'
|
||||||
import { config } from '../../../context'
|
import { config } from '../../../context'
|
||||||
|
|
||||||
const msRcConfig = config.messageScan?.humanCorrections?.allow
|
const msRcConfig = config.messageScan?.humanCorrections?.allow
|
||||||
@@ -70,7 +70,7 @@ export default new Command({
|
|||||||
`The provided message has been trained as \`${label}\`. Thank you for your contribution!`,
|
`The provided message has been trained as \`${label}\`. Thank you for your contribution!`,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
ephemeral: true,
|
flags: MessageFlags.Ephemeral,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import Command from '$/classes/Command'
|
import Command from '$/classes/Command'
|
||||||
import CommandError, { CommandErrorType } from '$/classes/CommandError'
|
import CommandError, { CommandErrorType } from '$/classes/CommandError'
|
||||||
import type { ConfigMessageScanResponseLabelConfig } from 'config.schema'
|
import type { ConfigMessageScanResponseLabelConfig } from 'config.schema'
|
||||||
import { type APIStringSelectComponent, ComponentType } from 'discord.js'
|
import { type APIStringSelectComponent, ComponentType, MessageFlags } from 'discord.js'
|
||||||
import { config } from '../../../context'
|
import { config } from '../../../context'
|
||||||
|
|
||||||
const msRcConfig = config.messageScan?.humanCorrections?.allow
|
const msRcConfig = config.messageScan?.humanCorrections?.allow
|
||||||
@@ -44,7 +44,7 @@ export default new Command({
|
|||||||
type: ComponentType.ActionRow,
|
type: ComponentType.ActionRow,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
ephemeral: true,
|
flags: MessageFlags.Ephemeral,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import CommandError from '$/classes/CommandError'
|
import CommandError from '$/classes/CommandError'
|
||||||
import { createStackTraceEmbed } from '$utils/discord/embeds'
|
import { createStackTraceEmbed } from '$utils/discord/embeds'
|
||||||
import { on, withContext } from '$utils/discord/events'
|
import { on, withContext } from '$utils/discord/events'
|
||||||
|
import { MessageFlags } from 'discord.js'
|
||||||
|
|
||||||
withContext(on, 'interactionCreate', async (context, interaction) => {
|
withContext(on, 'interactionCreate', async (context, interaction) => {
|
||||||
if (!interaction.isChatInputCommand()) return
|
if (!interaction.isChatInputCommand()) return
|
||||||
@@ -20,7 +21,7 @@ withContext(on, 'interactionCreate', async (context, interaction) => {
|
|||||||
|
|
||||||
await interaction[interaction.replied ? 'followUp' : 'reply']({
|
await interaction[interaction.replied ? 'followUp' : 'reply']({
|
||||||
embeds: [err instanceof CommandError ? err.toEmbed() : createStackTraceEmbed(err)],
|
embeds: [err instanceof CommandError ? err.toEmbed() : createStackTraceEmbed(err)],
|
||||||
ephemeral: true,
|
flags: MessageFlags.Ephemeral,
|
||||||
})
|
})
|
||||||
|
|
||||||
// 100 and up are user errors
|
// 100 and up are user errors
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import CommandError from '$/classes/CommandError'
|
import CommandError from '$/classes/CommandError'
|
||||||
import { createStackTraceEmbed } from '$utils/discord/embeds'
|
import { createStackTraceEmbed } from '$utils/discord/embeds'
|
||||||
import { on, withContext } from '$utils/discord/events'
|
import { on, withContext } from '$utils/discord/events'
|
||||||
|
import { MessageFlags } from 'discord.js'
|
||||||
|
|
||||||
withContext(on, 'interactionCreate', async (context, interaction) => {
|
withContext(on, 'interactionCreate', async (context, interaction) => {
|
||||||
if (!interaction.isContextMenuCommand()) return
|
if (!interaction.isContextMenuCommand()) return
|
||||||
@@ -20,7 +21,7 @@ withContext(on, 'interactionCreate', async (context, interaction) => {
|
|||||||
logger.error(`Error while executing command ${interaction.commandName}:`, err)
|
logger.error(`Error while executing command ${interaction.commandName}:`, err)
|
||||||
await interaction[interaction.replied ? 'followUp' : 'reply']({
|
await interaction[interaction.replied ? 'followUp' : 'reply']({
|
||||||
embeds: [err instanceof CommandError ? err.toEmbed() : createStackTraceEmbed(err)],
|
embeds: [err instanceof CommandError ? err.toEmbed() : createStackTraceEmbed(err)],
|
||||||
ephemeral: true,
|
flags: MessageFlags.Ephemeral,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,7 +3,12 @@ import { handleUserResponseCorrection } from '$/utils/discord/messageScan'
|
|||||||
import { createErrorEmbed, createStackTraceEmbed, createSuccessEmbed } from '$utils/discord/embeds'
|
import { createErrorEmbed, createStackTraceEmbed, createSuccessEmbed } from '$utils/discord/embeds'
|
||||||
import { on, withContext } from '$utils/discord/events'
|
import { on, withContext } from '$utils/discord/events'
|
||||||
|
|
||||||
import type { ButtonInteraction, StringSelectMenuInteraction, TextBasedChannel } from 'discord.js'
|
import {
|
||||||
|
type ButtonInteraction,
|
||||||
|
MessageFlags,
|
||||||
|
type StringSelectMenuInteraction,
|
||||||
|
type TextBasedChannel,
|
||||||
|
} from 'discord.js'
|
||||||
import { eq } from 'drizzle-orm'
|
import { eq } from 'drizzle-orm'
|
||||||
|
|
||||||
// No permission check required as it is already done when the user reacts to a bot response
|
// No permission check required as it is already done when the user reacts to a bot response
|
||||||
@@ -26,7 +31,7 @@ withContext(on, 'interactionCreate', async (context, interaction) => {
|
|||||||
if (!response)
|
if (!response)
|
||||||
return void (await interaction.reply({
|
return void (await interaction.reply({
|
||||||
content: "I don't recall having sent this response, so I cannot correct it.",
|
content: "I don't recall having sent this response, so I cannot correct it.",
|
||||||
ephemeral: true,
|
flags: MessageFlags.Ephemeral,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -91,7 +96,7 @@ withContext(on, 'interactionCreate', async (context, interaction) => {
|
|||||||
logger.error('Failed to handle correct response interaction:', e)
|
logger.error('Failed to handle correct response interaction:', e)
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
embeds: [createStackTraceEmbed(e)],
|
embeds: [createStackTraceEmbed(e)],
|
||||||
ephemeral: true,
|
flags: MessageFlags.Ephemeral,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { createErrorEmbed, createStackTraceEmbed, createSuccessEmbed } from '$utils/discord/embeds'
|
import { createErrorEmbed, createStackTraceEmbed, createSuccessEmbed } from '$utils/discord/embeds'
|
||||||
import { on, withContext } from '$utils/discord/events'
|
import { on, withContext } from '$utils/discord/events'
|
||||||
|
import { MessageFlags, type TextBasedChannel } from 'discord.js'
|
||||||
import type { TextBasedChannel } from 'discord.js'
|
|
||||||
|
|
||||||
withContext(on, 'interactionCreate', async (context, interaction) => {
|
withContext(on, 'interactionCreate', async (context, interaction) => {
|
||||||
const {
|
const {
|
||||||
@@ -28,7 +27,7 @@ withContext(on, 'interactionCreate', async (context, interaction) => {
|
|||||||
'Thank you for your contribution! Unfortunately, the message could not be found.',
|
'Thank you for your contribution! Unfortunately, the message could not be found.',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
ephemeral: true,
|
flags: MessageFlags.Ephemeral,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const selectedLabel = interaction.values[0]!
|
const selectedLabel = interaction.values[0]!
|
||||||
@@ -40,13 +39,13 @@ withContext(on, 'interactionCreate', async (context, interaction) => {
|
|||||||
`Thank you for your contribution! The selected message is being trained as \`${selectedLabel}\`. 🎉`,
|
`Thank you for your contribution! The selected message is being trained as \`${selectedLabel}\`. 🎉`,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
ephemeral: true,
|
flags: MessageFlags.Ephemeral,
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error('Failed to handle train message interaction:', e)
|
logger.error('Failed to handle train message interaction:', e)
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
embeds: [createStackTraceEmbed(e)],
|
embeds: [createStackTraceEmbed(e)],
|
||||||
ephemeral: true,
|
flags: MessageFlags.Ephemeral,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
9
bun.lock
9
bun.lock
@@ -25,7 +25,7 @@
|
|||||||
},
|
},
|
||||||
"apis/websocket": {
|
"apis/websocket": {
|
||||||
"name": "@revanced/bot-websocket-api",
|
"name": "@revanced/bot-websocket-api",
|
||||||
"version": "1.0.0-dev.10",
|
"version": "1.0.1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@revanced/bot-shared": "workspace:*",
|
"@revanced/bot-shared": "workspace:*",
|
||||||
"@sapphire/async-queue": "^1.5.5",
|
"@sapphire/async-queue": "^1.5.5",
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
},
|
},
|
||||||
"bots/discord": {
|
"bots/discord": {
|
||||||
"name": "@revanced/discord-bot",
|
"name": "@revanced/discord-bot",
|
||||||
"version": "1.0.0-dev.36",
|
"version": "1.1.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/builders": "^1.10.1",
|
"@discordjs/builders": "^1.10.1",
|
||||||
"@discordjs/rest": "^2.4.3",
|
"@discordjs/rest": "^2.4.3",
|
||||||
@@ -74,8 +74,8 @@
|
|||||||
"name": "@revanced/bot-shared",
|
"name": "@revanced/bot-shared",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bson": "^6.8.0",
|
"bson": "^6.10.3",
|
||||||
"chalk": "^5.3.0",
|
"chalk": "^5.4.1",
|
||||||
"tracer": "^1.3.0",
|
"tracer": "^1.3.0",
|
||||||
"valibot": "^0.30.0",
|
"valibot": "^0.30.0",
|
||||||
},
|
},
|
||||||
@@ -88,6 +88,7 @@
|
|||||||
"lefthook",
|
"lefthook",
|
||||||
],
|
],
|
||||||
"patchedDependencies": {
|
"patchedDependencies": {
|
||||||
|
"discord.js@14.18.0": "patches/discord.js@14.18.0.patch",
|
||||||
"@semantic-release/npm@12.0.1": "patches/@semantic-release%2Fnpm@12.0.1.patch",
|
"@semantic-release/npm@12.0.1": "patches/@semantic-release%2Fnpm@12.0.1.patch",
|
||||||
"drizzle-kit@0.22.8": "patches/drizzle-kit@0.22.8.patch",
|
"drizzle-kit@0.22.8": "patches/drizzle-kit@0.22.8.patch",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -56,6 +56,7 @@
|
|||||||
"patchedDependencies": {
|
"patchedDependencies": {
|
||||||
"@semantic-release/npm@12.0.1": "patches/@semantic-release%2Fnpm@12.0.1.patch",
|
"@semantic-release/npm@12.0.1": "patches/@semantic-release%2Fnpm@12.0.1.patch",
|
||||||
"drizzle-kit@0.22.8": "patches/drizzle-kit@0.22.8.patch",
|
"drizzle-kit@0.22.8": "patches/drizzle-kit@0.22.8.patch",
|
||||||
"decancer@3.2.4": "patches/decancer@3.2.4.patch"
|
"decancer@3.2.4": "patches/decancer@3.2.4.patch",
|
||||||
|
"discord.js@14.18.0": "patches/discord.js@14.18.0.patch"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
17
patches/discord.js@14.18.0.patch
Normal file
17
patches/discord.js@14.18.0.patch
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Make Message#reply work with { flags: MessageFlags.Ephemeral } in typings
|
||||||
|
# So our Command system doesn't break
|
||||||
|
diff --git a/typings/index.d.mts b/typings/index.d.mts
|
||||||
|
index 645b870..fa93158 100644
|
||||||
|
--- a/typings/index.d.mts
|
||||||
|
+++ b/typings/index.d.mts
|
||||||
|
@@ -6764,8 +6764,8 @@ export interface MessageCreateOptions extends BaseMessageOptionsWithPoll {
|
||||||
|
stickers?: readonly StickerResolvable[];
|
||||||
|
flags?:
|
||||||
|
| BitFieldResolvable<
|
||||||
|
- Extract<MessageFlagsString, 'SuppressEmbeds' | 'SuppressNotifications'>,
|
||||||
|
- MessageFlags.SuppressEmbeds | MessageFlags.SuppressNotifications
|
||||||
|
+ Extract<MessageFlagsString, 'SuppressEmbeds' | 'SuppressNotifications' | 'Ephemeral'>,
|
||||||
|
+ MessageFlags.SuppressEmbeds | MessageFlags.SuppressNotifications | MessageFlags.Ephemeral
|
||||||
|
>
|
||||||
|
| undefined;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user