how to make this concept work?

i'm trying to make a command where i can set the bot's status & then choose the playing/watching/listening etc type in a select menu, & here is this attempt:
const { ComponentType, ActivityType, ActionRowBuilder, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('status')
.setDescription('Select a status for the bot')
.addStringOption(option =>
option.setName('status')
.setDescription('The status to set')
.setRequired(true)
.setMaxLength(128)),
async execute(interaction) {
const status = interaction.options.getString('status');
const select = new StringSelectMenuBuilder()
.setCustomId('type')
.setPlaceholder('Type of status')
.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel('Playing')
.setDescription('Playing /status')
.setValue('Playing'),
new StringSelectMenuOptionBuilder()
.setLabel('Watching')
.setDescription('Watching /status')
.setValue('Watching'),
new StringSelectMenuOptionBuilder()
.setLabel('Listening')
.setDescription('Listening to /status')
.setValue('Listening'),
);

const row = new ActionRowBuilder()
.addComponents(select);

const response = await interaction.reply({
content: 'Choose the type of status you want to set',
components: [row],
});
const collector = response.createMessageComponentCollector({ componentType: ComponentType.StringSelect, time: 3_600_000 });
collector.on('collect', async i => {
const selection = i.values[0].toLowerCase();
await interaction.client.user.setActivity(interaction.options.getString('status'), { type: ActivityType.select });
await i.reply(`${i.user} has set my status as ${selection} ${status}!`);
});
},
};
const { ComponentType, ActivityType, ActionRowBuilder, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('status')
.setDescription('Select a status for the bot')
.addStringOption(option =>
option.setName('status')
.setDescription('The status to set')
.setRequired(true)
.setMaxLength(128)),
async execute(interaction) {
const status = interaction.options.getString('status');
const select = new StringSelectMenuBuilder()
.setCustomId('type')
.setPlaceholder('Type of status')
.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel('Playing')
.setDescription('Playing /status')
.setValue('Playing'),
new StringSelectMenuOptionBuilder()
.setLabel('Watching')
.setDescription('Watching /status')
.setValue('Watching'),
new StringSelectMenuOptionBuilder()
.setLabel('Listening')
.setDescription('Listening to /status')
.setValue('Listening'),
);

const row = new ActionRowBuilder()
.addComponents(select);

const response = await interaction.reply({
content: 'Choose the type of status you want to set',
components: [row],
});
const collector = response.createMessageComponentCollector({ componentType: ComponentType.StringSelect, time: 3_600_000 });
collector.on('collect', async i => {
const selection = i.values[0].toLowerCase();
await interaction.client.user.setActivity(interaction.options.getString('status'), { type: ActivityType.select });
await i.reply(`${i.user} has set my status as ${selection} ${status}!`);
});
},
};
however every selection i make simply returns ActivityType.Playing despite me trying to make the Playing give whichever value, i'm pretty sure i missed something but i can't really figure out what. no worries if no help is able to be given, but i feel like there's probably an easy fix or i overlooked something?
13 Replies
d.js toolkit
d.js toolkit2y ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
beck
beckOP2y ago
it works to retrieve the playing thing & set the status, unless i changed that last minute but not watching/listening im not sure if i can do it like that in such condensed code
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
beck
beckOP2y ago
i used the template from the guide website and didn't think to change it yet, could it be an issue?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
beck
beckOP2y ago
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
beck
beckOP2y ago
yeah idk why i didn't even think about it
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
beck
beckOP2y ago
yeah i just wanted to use a select menu for it thank you
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
beck
beckOP2y ago
oh okay, i will try that
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server