Closed NubTheFatMan closed 6 years ago
Your bot role should be higher than role, which it adds
Yes, I have doubled checked that and copied and pasted all ID's at least 3 times
I'm not sure why this happens, so let's gather some more info.
Change your code snippet to this: bot.addToRole({serverID: bot.channels[channelID].guild_id, userID: bot.id, roleID: "422475094611460096"}, console.log)
and set it up to be run as a command instead of in .on("ready"
.
Use the command and see what gets printed to the console, and whether the role assignment works or not.
Something else important: how did you get the roleID to paste into your code? Did you mention the role and right-click its name in chat, then "copy ID"?
So I'm getting this error:
ResponseError: Could not add role at handleResCB (G:\Bot\node_modules\discord.io\lib\index.js:1385:10) at G:\Bot\node_modules\discord.io\lib\index.js:1160:3 at Gunzip.cb (G:\Bot\node_modules\discord.io\lib\index.js:1471:13) at Gunzip.zlibBufferOnError (zlib.js:93:8) at Gunzip.emit (events.js:127:13) at Zlib.zlibOnError [as onerror] (zlib.js:145:8) name: 'ResponseError', statusCode: 404, statusMessage: 'NOT FOUND', response: { code: 10011, message: 'Unknown Role' } }
Yes, I copied and pasted by mentioning and copying the ID of the role. How else can you get the ID of a role?
Anyways, not sure how it says it's an unknown role.
I even created a new role and copied it's ID, still says it doesn't exist
Yes, I copied and pasted by mentioning and copying the ID of the role. How else can you get the ID of a role?
A few ways, but not like that! That copies the ID of the message that you clicked on, not the ID of the role. (You can test this yourself by sending two different messages, each with the role mention in it. Right-click each role, copy the IDs and compare them. They're different! That's because they're the ID of each message.)
So, how do you actually get the role ID? There are a couple of ways.
<@&12345678>
. The numbers are the roleID.Object.values(bot.servers[serverID].roles).find(r => r.name == "Name of your role").id
(or just check bot.servers[serverID].roles
and look through the info manually)Anyways, not sure how it says it's an unknown role.
Tada!
Also, you can mention your role with "\", like: \@Moderator
Thank you for helping. Could never figure out why it wasn't working
On my bot, I'm trying to get adding roles working, so I am trying to get the bot to add a custom role I have set. I have the bot set as administrator but it still won't add itself to my specified role. The admin role it is assigned to is above the role I want it to add. Here is my code snip:
bot.addToRole({ serverID: "421131465909338112", userID: "421127002968555530", roleID: "422475094611460096" }, function(err, res){ bot.sendMessage({ to: "421131465909338114", message: err }); });
This is in thebot.on('ready', function());
Every time I start the bot, the error gets printed into the chat channel I have specified, with the text "ResponseError: Could not add role"