Skip to content

Commit

Permalink
fix/ephemeral deprecated (#451)
Browse files Browse the repository at this point in the history
* upgrade: node packages

* feat: ADR

* fix: deprecated ephemeral in response message

---------

Co-authored-by: JustDams <[email protected]>
  • Loading branch information
JustDams and web-flow authored Feb 28, 2025
1 parent 14c4e44 commit 8091f91
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
8 changes: 7 additions & 1 deletion commands/roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const successCard = require('../templates/successCard')
const { updateRoles, getRoleIds } = require('../functions/roles')
const { getTranslations, getTranslation } = require('../languages/setup')
const { isInteractionSubcommandEqual, getInteractionOption } = require('../functions/utility')
const { ephemeral } = require('./team')

const SETUP = 'setup'
const GENERATE = 'generate'
Expand Down Expand Up @@ -226,6 +227,7 @@ module.exports = {
descriptionLocalizations: getTranslations('options.setupRoles'),
type: Discord.ApplicationCommandOptionType.Subcommand,
slash: true,
ephemeral: true,
options: [
...Array(10).fill('').map((k, i) => {
return {
Expand All @@ -252,6 +254,7 @@ module.exports = {
descriptionLocalizations: getTranslations('options.generateRoles'),
type: Discord.ApplicationCommandOptionType.Subcommand,
slash: true,
ephemeral: true,
options: [
{
name: 'remove_old',
Expand All @@ -267,7 +270,8 @@ module.exports = {
description: getTranslation('options.removeRoles', 'en-US'),
descriptionLocalizations: getTranslations('options.removeRoles'),
type: Discord.ApplicationCommandOptionType.Subcommand,
slash: true
slash: true,
ephemeral: true
},
{
name: SETUP_ELO,
Expand All @@ -276,6 +280,7 @@ module.exports = {
type: Discord.ApplicationCommandOptionType.Subcommand,
slash: true,
premium: true,
ephemeral: true,
options: [
{
name: 'role_name',
Expand Down Expand Up @@ -317,6 +322,7 @@ module.exports = {
descriptionLocalizations: getTranslations('options.removeEloRole'),
type: Discord.ApplicationCommandOptionType.Subcommand,
slash: true,
ephemeral: true,
options: [
{
name: 'role',
Expand Down
15 changes: 8 additions & 7 deletions events/interactionCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,24 +150,25 @@ module.exports = {
*/
else if (interaction.client.commands.has(interaction.commandName)) {
const command = interaction.client.commands.get(interaction.commandName)
const subCommand = command.options
.filter(option => option.type === ApplicationCommandOptionType.Subcommand && option.name === interaction.options.getSubcommand())
.shift()

interaction
.deferReply({ ephemeral: command.ephemeral })
.deferReply({ ephemeral: command.ephemeral ?? subCommand?.ephemeral })
.then(async () => {
const premiumSubCommand = command.options
.filter(option => option.type === ApplicationCommandOptionType.Subcommand && option.premium && option.name === interaction.options.getSubcommand())

if (premiumSubCommand.length > 0) {
const premiumSubCommand = subCommand?.premium
if (premiumSubCommand) {
const isPremium = await currentGuildIsPremium(interaction.client, interaction.guildId)
if (!isPremium) {
interaction.followUp({
ephemeral: true,
content: ' ',
...premiumCard(interaction.locale),
}).catch((error) => errorHandler(interaction, error))
return
}
}

CommandsStats.create(interaction.commandName, 'command', interaction)
command?.execute(interaction)
.then(resp => {
Expand Down

0 comments on commit 8091f91

Please sign in to comment.