#'await' expressions are only allowed within async functions and at the top levels of modules
68 messages · Page 1 of 1 (latest)
ohh
thanks
also the command its not working
Of course, and what do you mean by "not working", what happens when you use it? Any errors?
i write the command and nothing happens
did i missed something?
Does it say "Application did not respond" or something, and no errors in console?
nope, nothing
its like the script its not seeing my commands folder and command file
Did you run the script?
what? node .\index.js isn't that the command that runs the entire script?
Once you fill in these values, run
node deploy-commands.jsin your project directory to register your commands to the guild specified. If you see the success message, check for the commands in the server by typing/! If all goes well, you should be able to run them and see your bot's response in Discord!
i did that
Does the command show on Discord?
thats why i am asking u, i know i am stupid but not that stupid
haha
nope
Can you show deploy-commands.js?
i've just copy pasted from the guide
the clientId i took it from there
and the guildId from there:
Refresh discord sometimes fix the issue
it works actually
i started develop a command by myself
but i get this error
const { SlashCommandBuilder } = require('discord.js');
module.exports = {
cooldown: 5,
data: new SlashCommandBuilder()
.setName('to')
.setDescription('Activeaza ticketele!'),
async execute(interaction) {
// Set the allowed role IDs
const allowedRoleIds = ['1084567084224217178', '1090427272059695224'];
// Check if the user invoking the command has one of the allowed roles
const hasAllowedRole = interaction.member.roles.cache.some(role => allowedRoleIds.includes(role.id));
if (!hasAllowedRole) {
return interaction.reply({
content: 'Nu ai permisiunea de a folosi aceasta comanda.',
ephemeral: true
});
}
// Get the channel where you want to create the button
const channel = interaction.client.channels.cache.get('1090749603625832608');
// Create the message with the button
const message = await channel.send({
content: 'Click this button to do something!',
components: [{
type: 'ACTION_ROW',
components: [{
type: 'BUTTON',
style: 'PRIMARY',
label: 'Click me!',
customId: 'button_click'
}]
}]
});
await interaction.reply('Button created!');
},
};
i just want to send a button to another channel if the user that write the command has the permision
you should use ActionRowBuilder and ButtonBuilder instead of manually writing them as an object. it's complaining that there's no toJSON function on your button since it's just a simple object
now i get this
MessageBuilder on line 118, is that a real class? i dont see it anywhere
You on v13 or v14
why do i get that?
14.8.0
Personally I’d recommend just using the builders
It prevents errors like these quite a lot
Also don’t use nested listeners
i just want when i press this button to show me this:
So use an interactionCreate outside of that file and handle everything in one event
all what i have in my script its not the same as in the guide
i will try
client.on('interactionCreate', async interaction => {
if (!interaction.isButton()) return;
if (interaction.customId === 'primary') {
const modal = new ModalBuilder()
.setCustomId('modal-tickets')
.setTitle('Cox Family Support - Tickets');
const problemInput = new TextInputBuilder()
.setCustomId('problemInput')
.setLabel("In ce problema dorest sa ne contactezi?")
.setStyle(TextInputStyle.Paragraph);
const selectMenu = new SelectMenuBuilder()
.setCustomId('select')
.setPlaceholder('Nothing selected')
.addOptions(
{
label: 'Select me',
description: 'This is a description',
value: 'first_option',
},
{
label: 'You can select me too',
description: 'This is also a description',
value: 'second_option',
},
);
const firstActionRow = new ActionRowBuilder()
.addComponents(problemInput, selectMenu);
modal.addComponents(firstActionRow);
await interaction.showModal(modal);
}
});```
i just want to add the constant selectMenu
why its not working like the inputs?
what is this?
DiscordAPIError[50035]: Invalid Form Body
name[BASE_TYPE_REQUIRED]: This field is required
at SequentialHandler.runRequest (C:\Users\sstru\Desktop\cox-bots\ticket-bot\node_modules@discordjs\rest\dist\index.js:933:15)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async SequentialHandler.queueRequest (C:\Users\sstru\Desktop\cox-bots\ticket-bot\node_modules@discordjs\rest\dist\index.js:712:14)
at async REST.request (C:\Users\sstru\Desktop\cox-bots\ticket-bot\node_modules@discordjs\rest\dist\index.js:1321:22)
at async GuildChannelManager.create (C:\Users\sstru\Desktop\cox-bots\ticket-bot\node_modules\discord.js\src\managers\GuildChannelManager.js:170:18)
at async Client.<anonymous> (C:\Users\sstru\Desktop\cox-bots\ticket-bot\index.js:63:21) {
rawError: {
code: 50035,
errors: { name: [Object] },
message: 'Invalid Form Body'
},
code: 50035,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/guilds/1084566469767069827/channels',
requestBody: {
files: undefined,
json: {
name: undefined,
topic: undefined,
type: undefined,
nsfw: undefined,
bitrate: undefined,
user_limit: undefined,
parent_id: undefined,
position: undefined,
permission_overwrites: undefined,
rate_limit_per_user: undefined,
rtc_region: undefined,
video_quality_mode: undefined,
available_tags: undefined,
default_reaction_emoji: undefined,
default_auto_archive_duration: undefined,
default_sort_order: undefined,
default_forum_layout: undefined
}
}
}
An error telling you that channels need a name when creating them
the modal popup is not closing
i dont get any errors