I am trying to make a discord bot for someone and there is this command that I get stuck on, the giverole
one. Particularly, the arguments.shift
part of it.
Here is my code:
client.on('message', message => {
if (message.content.startsWith(`${prefix}giverole`)) {
if (!message.member.hasPermission("ADMINISTRATOR")) {
message.channel.send("Vous n'avez pas la permission d'utiliser cette commande.")
return;
}
const targetUser = message.mentions.users.first()
if (!targetUser) {
message.reply('Please specify someone to give a role to.')
return
}
arguments.shift()
const roleName = arguments.join(' ')
const { guild } = message
const role = guild.roles.cache.find((role) => {
return role.name === roleName
})
if (!role) {
message.reply(`There is no role with the name "${roleName}"`)
return
}
const member = guild.members.cache.get(targetUser.id)
member.roles.add(role)
message.reply(`that user now has the "${roleName}" role`)
}
}
And I receive this error:
TypeError: arguments.shift is not a function
The error may be that arguments isn't passed anywhere, yet I don't know where to place it.
question from:https://stackoverflow.com/questions/66059581/arguments-shift-is-not-a-function-discord-js