Answer the question
In order to leave comments, you need to log in
Gives an error setRequired is not a function, there is a function in the documentation, why?
const Discord = require('discord.js');
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
data: new SlashCommandBuilder()
.setName('ban')
.setDescription('Отправляет ваш аватар/аватар упомянутого пользователя')
.addUserOption(option => option
.setName('banuser')
.setDescription('Выберите пользователя'))
.setRequired(true)
.addNumberOption(option => option
.setName('days')
.setDescription('Количество дней бана, от 0 до 7'))
.addStringOption(option => option
.setName('reason')
.setDescription('Укажите причину'))
.setRequired(true),
async execute(interaction) {
let bUser = interaction.options.getMember('banuser')
let reason = interaction.options.getString('reason')
let days = interaction.options.getNumber('days')
if(!bUser) return interaction.reply({content: 'Укажите пользователя, которого вы хотите забанить!', ephemeral: true})
if(bUser.id === interaction.user.id) interaction.reply({content: "Вы не можете забанить самого себя!", ephemeral: true});
if (!interaction.guild.me.permissions.has("BAN_MEMBERS")) return interaction.reply({content: "У меня нет прав!", ephemeral: true})
if (!interaction.member.permissions.has("BAN_MEMBERS")) return interaction.reply({content: "У вас нет прав!", ephemeral: true})
if (!reason) return interaction.reply({content: "Вы не указали причину!", ephemeral: true})
if (!days) days = 0
bUser.ban({reason: reason, days: days})
const ban_embed = new Discord.MessageEmbed()
.setColor('#db0f0f')
.addFields(
{ name: 'Пользователь', value: `<@${interaction.user.id}>` },
{ name: 'Забанил', value: `<@${bUser.id}>` },
{ name: 'По причине', value: reason }
);
interaction.reply({embeds: [ban_embed]})
},
};
TypeError: (intermediate value).setName(...).setDescription(...).addUserOption(...).setRequired is not a function
at Object.<anonymous> (C:\Users\*\OneDrive\Документы\discord-bots\banette-bot\commands\ban.js:11:5)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\*\OneDrive\Документы\discord-bots\banette-bot\index.js:14:18)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
Answer the question
In order to leave comments, you need to log in
setDescription('Выберите пользователя'))
- you closed the extra bracket here
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question