Guild member add was registered.
DiscordAPIError: Invalid Form Body
user_id: Value “<@!516700379359084580>” is not snowflake.
at RequestHandler.execute (C:\Users\danie\OneDrive\Desktop\MedusaBot\node_modules\discord.js\src\rest\RequestHandler.js:170:25)
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
method: ‘put’,
path: ‘/guilds/716901331062882394/bans/<@!516700379359084580>?days=0’,
code: 50035,
httpStatus: 400
}
This shows up when attempting to use my !ban command
Please, give code this command.
module.exports = {
run: async(client, message, args) => {
if(!message.member.hasPermission('BAN_MEMBERS')) {
message.channel.send("You don't have permission to use that command.");
}
else {
try {
let bannedMember = await message.guild.members.ban(args);
if(bannedMember)
console.log(bannedMember.tag + " was banned.");
}
catch(err) {
console.log(err);
}
}
},
aliases: [],
description: 'Bans a guild member by their ID'
}
In fact none of my commands work correctly. They all say cannot find user or cannot find role.
you should change that to let bannedMember = message.mentions.members.first();
TypeError: message.guild.members.first is not a function
and you dont actually ban them anywhere. You will need bannedMember.ban
somewhere
Never mind i see im an idiot disregard that reply
We are getting somewhere. It now says this: undefined was banned.
It also still doesnt ban. I added bannedMember.ban here:
else {
try {
let bannedMember = message.mentions.members.first();
bannedMember.ban;
if(bannedMember)
console.log(bannedMember.tag + " was banned.");
}
message.guild.member(bannedMember).ban('reason');
This worked, thank you. Any way to fix the console saying “Undefined was banned”?
if(bannedMember) {
console.log(`${bannedMember.username}#${bannedMember.discriminator} was banned.`);
}
Also this does not log the ban reason. Is it possible to add that into my code? I know im asking a lot but im new to this stuff and dont know how to problem shoot
you need to console.log before banning the person
let reason = args.slice(0).join(' ');
if(!reason) {
reason = "No reason given";
}
else {
reason = `${reason}`
}
To ban with a reason, you need 2 arguments. The first argument is responsible for mentioning the participant, and the second argument is for the reason for the ban.
let argsfix = args.join(" ").slice(22);
let bReason = argsfix;
let bUser = message.mentions.members.first();
if(!bReason) {
bReason = ‘Your custom reason’;
}
message.guild.member(bUser).ban(bReason);
This will be the last time I annoy you all.
TypeError: args.slice(…).join is not a function
at run (C:\Users\danie\OneDrive\Desktop\MedusaBot\commands\mod\ban.js:10:44)
at module.exports (C:\Users\danie\OneDrive\Desktop\MedusaBot\events\message\message.js:8:37)
at Client.emit (events.js:315:20)
at MessageCreateAction.handle (C:\Users\danie\OneDrive\Desktop\MedusaBot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\danie\OneDrive\Desktop\MedusaBot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\danie\OneDrive\Desktop\MedusaBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31)
at WebSocketShard.onPacket (C:\Users\danie\OneDrive\Desktop\MedusaBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:436:22)
at WebSocketShard.onMessage (C:\Users\danie\OneDrive\Desktop\MedusaBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10)
at WebSocket.onMessage (C:\Users\danie\OneDrive\Desktop\MedusaBot\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (C:\Users\danie\OneDrive\Desktop\MedusaBot\node_modules\ws\lib\websocket.js:800:20)
at Receiver.emit (events.js:315:20)
at Receiver.dataMessage (C:\Users\danie\OneDrive\Desktop\MedusaBot\node_modules\ws\lib\receiver.js:436:14)
at Receiver.getData (C:\Users\danie\OneDrive\Desktop\MedusaBot\node_modules\ws\lib\receiver.js:366:17)
at Receiver.startLoop (C:\Users\danie\OneDrive\Desktop\MedusaBot\node_modules\ws\lib\receiver.js:142:22)
at Receiver._write (C:\Users\danie\OneDrive\Desktop\MedusaBot\node_modules\ws\lib\receiver.js:77:10)
module.exports = {
run: async(client, message, args) => {
if(!message.member.hasPermission('BAN_MEMBERS')) {
message.channel.send("You don't have permission to use that command.");
}
else {
try {
let bannedMember = message.mentions.members.first();
let reason = args.slice(0).join(' ');
if(!reason) {
reason = "No reason given";
}
else {
reason = `${reason}`
}
message.guild.member(bannedMember).ban('reason');
if(bannedMember)
console.log(bannedMember.tag + " was banned.");
}
catch(err) {
console.log(err);
}
}
},
aliases: [],
description: 'Bans a guild member by their ID'
}
That is my error message and that is what it looks like after adding the reason code
run: async(client, message, args) => {
if(!message.member.hasPermission('BAN_MEMBERS')) {
message.channel.send("You don't have permission to use that command.");
}
else {
try {
let bannedMember = message.mentions.members.first();
let messageArray = message.content.split(' ');
let cmd = messageArray[0];
let args = messageArray.slice(1);
let reason = args.join(" ").slice(22);
if(!reason) {
reason = "No reason given";
}
else {
reason = `${reason}`
}
message.guild.member(bannedMember).ban(reason);
if(bannedMember)
console.log(`${bannedMember.user.username}#${bannedMember.user.discriminator} was banned. Reason: ${reason}`);
}
catch(err) {
console.log(err);
}
}
},
aliases: ,
description: ‘Bans a guild member by their ID’
1 Like