error

const { SlashCommandBuilder, PermissionFlagsBits, Client } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
const { intersection } = require('lodash');
let time = 'time1'

module.exports = {
data: new SlashCommandBuilder()
.setName('mute')
.setDescription('mute user'),
async execute(interaction) {
const permission = interaction.roles.cache.has('1221367123889094708');
if (!permission) {
await interaction.reply({ content: ':x: | No perms', ephemeral: true });
} else {
const muteEmbed = new EmbedBuilder()
.setColor('#37393d')
.setTitle(`Mute`)
.addUserOption(option => option.setName('user').setDescription('User'))
.addStringOption(option => option.setName('reason').setDescription('Reason'))
.addFields({name: 'user', value: `<@${user}>\n`})
.addFields({name: 'moderator', value: `<@${interaction.user.id}>\n`})
.addFields({name: 'time', value: `<@${time}>\n`})
.addFields({name: 'reason', value: `<@${reason}>\n`})
.setTimestamp()
await interaction.reply({ embeds: [muteEmbed] });
}
}

}
const { SlashCommandBuilder, PermissionFlagsBits, Client } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
const { intersection } = require('lodash');
let time = 'time1'

module.exports = {
data: new SlashCommandBuilder()
.setName('mute')
.setDescription('mute user'),
async execute(interaction) {
const permission = interaction.roles.cache.has('1221367123889094708');
if (!permission) {
await interaction.reply({ content: ':x: | No perms', ephemeral: true });
} else {
const muteEmbed = new EmbedBuilder()
.setColor('#37393d')
.setTitle(`Mute`)
.addUserOption(option => option.setName('user').setDescription('User'))
.addStringOption(option => option.setName('reason').setDescription('Reason'))
.addFields({name: 'user', value: `<@${user}>\n`})
.addFields({name: 'moderator', value: `<@${interaction.user.id}>\n`})
.addFields({name: 'time', value: `<@${time}>\n`})
.addFields({name: 'reason', value: `<@${reason}>\n`})
.setTimestamp()
await interaction.reply({ embeds: [muteEmbed] });
}
}

}
console error https://srcb.in/fcYMo4ItCS
13 Replies
d.js toolkit
d.js toolkit8mo 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!
vekizxo
vekizxoOP8mo ago
I don't understand where I went wrong
Spaxter
Spaxter8mo ago
interaction.roles is not a thing did you mean interaction.member.roles?
vekizxo
vekizxoOP8mo ago
anyway error
Spaxter
Spaxter8mo ago
The same error?
alesi
alesi8mo ago
show the console error
vekizxo
vekizxoOP8mo ago
check footer bro
alesi
alesi8mo ago
oh sorry didnt see it this is your ban.js code?
vekizxo
vekizxoOP8mo ago
yeah mute code error when executing a command
alesi
alesi8mo ago
const permission = interaction.member.roles.cache.has('1221367123889094708'); try this the way your are catching your command is weird, i dont use slash commands but I think you should catch the message.member.roles.cache instead of a interaction check where are you calling your execute function
vekizxo
vekizxoOP8mo ago
work and also, how to make the option argument mandatory? .addUserOption(option => option.setName('target').setDescription('The user')) this
alesi
alesi8mo ago
hmm what is this supposed to do? never used that option on embeds
d.js docs
d.js docs8mo ago
:method: SlashCommandUserOption#setRequired() Marks the option as required
Want results from more Discord servers?
Add your server