when im starting the bot its not making the command. the code:
` const { Client, Intents, IntentsBitField } = require(‘discord.js’);
const { SlashCommandBuilder } = require(‘@discordjs/builders’);
const fs = require(‘fs’).promises;
<code>let running = false
const client = new Client({ intents: [IntentsBitField.Flags.Guilds] });
module.exports = {
data: new SlashCommandBuilder()
.setName('giverole')
.setDescription('Give a user a role.')
.addUserOption(option =>
option.setName('user')
.setDescription('The user to give the role to.')
.setRequired(true))
.addRoleOption(option =>
option.setName('role')
.setDescription('The role to give to the user.')
.setRequired(true)),
async execute(interaction) {
const guild = interaction.guild;
const member = guild.members.cache.get(interaction.options.getUser('user').id);
const role = interaction.options.getRole('role');
try {
await member.roles.add(role);
await interaction.reply(`The role ${role.name} has been added to ${member.user.username}.`);
} catch (error) {
console.error(error);
await interaction.reply('There was an error giving the role.');
}
},
};
client.login('MTI0ODcyNzAxMTIwODMzNTUwMA.GCxdnb.oS__BM_ZDzc0EdoeHOI1WH-ZXih_skmlSPDewA')`
</code>
<code>let running = false
const client = new Client({ intents: [IntentsBitField.Flags.Guilds] });
module.exports = {
data: new SlashCommandBuilder()
.setName('giverole')
.setDescription('Give a user a role.')
.addUserOption(option =>
option.setName('user')
.setDescription('The user to give the role to.')
.setRequired(true))
.addRoleOption(option =>
option.setName('role')
.setDescription('The role to give to the user.')
.setRequired(true)),
async execute(interaction) {
const guild = interaction.guild;
const member = guild.members.cache.get(interaction.options.getUser('user').id);
const role = interaction.options.getRole('role');
try {
await member.roles.add(role);
await interaction.reply(`The role ${role.name} has been added to ${member.user.username}.`);
} catch (error) {
console.error(error);
await interaction.reply('There was an error giving the role.');
}
},
};
client.login('MTI0ODcyNzAxMTIwODMzNTUwMA.GCxdnb.oS__BM_ZDzc0EdoeHOI1WH-ZXih_skmlSPDewA')`
</code>
let running = false
const client = new Client({ intents: [IntentsBitField.Flags.Guilds] });
module.exports = {
data: new SlashCommandBuilder()
.setName('giverole')
.setDescription('Give a user a role.')
.addUserOption(option =>
option.setName('user')
.setDescription('The user to give the role to.')
.setRequired(true))
.addRoleOption(option =>
option.setName('role')
.setDescription('The role to give to the user.')
.setRequired(true)),
async execute(interaction) {
const guild = interaction.guild;
const member = guild.members.cache.get(interaction.options.getUser('user').id);
const role = interaction.options.getRole('role');
try {
await member.roles.add(role);
await interaction.reply(`The role ${role.name} has been added to ${member.user.username}.`);
} catch (error) {
console.error(error);
await interaction.reply('There was an error giving the role.');
}
},
};
client.login('MTI0ODcyNzAxMTIwODMzNTUwMA.GCxdnb.oS__BM_ZDzc0EdoeHOI1WH-ZXih_skmlSPDewA')`
i tried to run it and do /giverole but its not making any commands.
New contributor
dwefw dfwdwdw is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.