jonathonor / syncBot

A bot that syncs roles between multiple discord servers.
https://www.jonsbots.com/syncBot
30 stars 17 forks source link

Issue when running /role-checker force-sync command #18

Closed zacharytbaldino closed 1 year ago

zacharytbaldino commented 1 year ago

Hello when running commands within a discord we are getting the following issues as well as an issue with "There was an error adding the role in the main server, see console for error.

syncbot ready!

at async SequentialHandler.queueRequest (C:\Users\Administrator\Desktop\sync

bot\G3NSyncBot\syncBot\node_modules\@discordjs\rest\dist\index.js:458:14) at async REST.request (C:\Users\Administrator\Desktop\syncbot\G3NSyncBot\syn cBot\node_modules\@discordjs\rest\dist\index.js:902:22) at async GuildMemberRoleManager.add (C:\Users\Administrator\Desktop\syncbot\ G3NSyncBot\syncBot\node_modules\discord.js\src\managers\GuildMemberRoleManager.j s:131:7) { requestBody: { files: undefined, json: undefined }, rawError: { message: 'Missing Permissions', code: 50013 }, code: 50013, status: 403, method: 'PUT', url: 'https://discord.com/api/v10/guilds/633376696866963466/members/1030350259 601276929/roles/646101087044239372' } C:\Users\Administrator\Desktop\syncbot\G3NSyncBot\syncBot\node_modules\@discordj s\rest\dist\index.js:659 throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData); ^

DiscordAPIError[50001]: Missing Access at SequentialHandler.runRequest (C:\Users\Administrator\Desktop\syncbot\G3NS yncBot\syncBot\node_modules\@discordjs\rest\dist\index.js:659:15) at process.processTicksAndRejections (node:internal/process/task_queues:95:5 ) at async SequentialHandler.queueRequest (C:\Users\Administrator\Desktop\sync bot\G3NSyncBot\syncBot\node_modules\@discordjs\rest\dist\index.js:458:14) at async REST.request (C:\Users\Administrator\Desktop\syncbot\G3NSyncBot\syn cBot\node_modules\@discordjs\rest\dist\index.js:902:22) at async GuildManager.fetch (C:\Users\Administrator\Desktop\syncbot\G3NSyncB ot\syncBot\node_modules\discord.js\src\managers\GuildManager.js:273:20) at async addRole (file:///C:/Users/Administrator/Desktop/syncbot/G3NSyncBot/ syncBot/run.js:195:30) { requestBody: { files: undefined, json: undefined }, rawError: { message: 'Missing Access', code: 50001 }, code: 50001, status: 403, method: 'GET', url: 'https://discord.com/api/v10/guilds/830623778601304095?with_counts=true' }

Node.js v18.3.0

Sometime while running the /role-checker command we get an error with Unable under issues with roleAnalyzeCallback

jonathonor commented 1 year ago

Hi, this is a permissions issue. It could be a variety of different missing permissions.

Please make sure you have followed the documentation closely. I would suspect that the bot is not above the role you are asking it to assign.

zacharytbaldino commented 1 year ago

I will look into the bot on our end. It does also crash with Unknown Member also. Assuming this is also permission based? Would giving it server admin potentially resolve this issue?

jonathonor commented 1 year ago

Unknown Member is a different issue I have dealt with in the past. Are you running the bot regular or in reverse?

zacharytbaldino commented 1 year ago

The bot is running in regular mode, we are currently syncing a backup server with just staff on it. Don't know if that could also be throwing that issue. But it's only after a handful of unknown member alerts in our logs channel that it eventually stops

jonathonor commented 1 year ago

Do you happen to know what's causing the Unknown Member error of have any logs?

For example, is it when someone is added to the synced server, when someone leaves the main server etc...

I'll be looking into this.

zacharytbaldino commented 1 year ago

It only seems to throw the error when a role is assigned to someone in the main that is not in the other. However I can monitor to see if it happens when someone joins when I am able to access. The VPS

jonathonor commented 1 year ago

@zacharytbaldino I made many updates to the bot yesterday while working with a user in my discord server who was having a very similar issue to you. Please get the latest changes from github and let me know if you still run into the issue. If so we can diagnose further.

zacharytbaldino commented 1 year ago

Awesome, I’ll grab that tonight and will let you know.

zacharytbaldino commented 1 year ago

Just updated the bot. Everything seems to be working as it should, it does not crash when running the command and the bot now shows [bit name] is think with the dots and it hold steady for quite sometime. Don’t know if the bot has a timeout that makes it say the application didn’t respond (the server has 1000+) members in it. The console is not recognizing non manageable users and bots however

zacharytbaldino commented 1 year ago

BB3AA6A7-EC83-4B09-AFC6-E0EC3D42E1C6 This is now what happens when running the role-checker sync-all command

jonathonor commented 1 year ago

The error you posted a screenshot of is not taking place in the role-checker command. Its actually caused by a user leaving the server, perhaps while the role-checker command is running....

I'll look into why it's failing nonetheless. I think I see the issue.

jonathonor commented 1 year ago

@zacharytbaldino I have just pushed a fix for the issue you sent a screenshot of

zacharytbaldino commented 1 year ago

513BDE39-2854-47C2-A6B9-83BC7496D5EC Now receiving this issue on tuning node run.js I have not changed anything with the config file

jonathonor commented 1 year ago

Do you still have a config.json file containing "applicationId" ? Make sure when you updated the bot from github you did not lose it.

zacharytbaldino commented 1 year ago

Mine contains, token and clientID

jonathonor commented 1 year ago

Ah sorry. Changing clientId to applicationId should fix the issue.

zacharytbaldino commented 1 year ago

Okay great, it seems to be working, I assume the bot in discord saying the application failed to respond is just a timeout on discords end as it throws it after about 30 mins but the bit is still running roleAnalyze

zacharytbaldino commented 1 year ago

image I receive this crash after running analyze. If this may be something on my end.

jonathonor commented 1 year ago

There is no way that the analyze should be taking 30 minutes. Likely the bot errores or something and never replied to the command.

I have never seen the unknown web hook error.

Anything else in the logs?

jonathonor commented 1 year ago

You can also run the bot now with node run.js debug To try and help you better find the issue.

zacharytbaldino commented 1 year ago

I will run it with the debug and see what I can find I can also post the log when I get to a computer

zacharytbaldino commented 1 year ago

Here is the full error that is thrown in the console.

It also does not sync the roles with force-sync. Unless it is not supposed to do that

C:\Users\Administrator\Desktop\syncbot\G3NSyncBot\syncBot\node_modules\@discordj s\rest\dist\index.js:659 throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData); ^

DiscordAPIError[50027]: Invalid Webhook Token at SequentialHandler.runRequest (C:\Users\Administrator\Desktop\syncbot\G3NS yncBot\syncBot\node_modules\@discordjs\rest\dist\index.js:659:15) at process.processTicksAndRejections (node:internal/process/task_queues:95:5 ) at async SequentialHandler.queueRequest (C:\Users\Administrator\Desktop\sync bot\G3NSyncBot\syncBot\node_modules\@discordjs\rest\dist\index.js:458:14) at async REST.request (C:\Users\Administrator\Desktop\syncbot\G3NSyncBot\syn cBot\node_modules\@discordjs\rest\dist\index.js:902:22) at async InteractionWebhook.editMessage (C:\Users\Administrator\Desktop\sync bot\G3NSyncBot\syncBot\node_modules\discord.js\src\structures\Webhook.js:320:15) at async ChatInputCommandInteraction.editReply (C:\Users\Administrator\Deskt op\syncbot\G3NSyncBot\syncBot\node_modules\discord.js\src\structures\interfaces\ InteractionResponses.js:151:21) at async file:///C:/Users/Administrator/Desktop/syncbot/G3NSyncBot/syncBot/r un.js:286:20 { requestBody: { files: [], json: { content: 'I went through and synced roles for 13545 members. I sent you a report in a DM.', tts: false, nonce: undefined, embeds: undefined, components: undefined, username: undefined, avatar_url: undefined, allowed_mentions: undefined, flags: 64, message_reference: undefined, attachments: undefined, sticker_ids: undefined, thread_name: undefined } }, rawError: { message: 'Invalid Webhook Token', code: 50027 }, code: 50027, status: 401, method: 'PATCH', url: 'https://discord.com/api/v10/webhooks/1045865288656240753/aW50ZXJhY3Rpb24 6MTA1MDk1NzgxMzQ5NDU5NTYzNDp0QmdiOVJvVW5PYk5seWFiQzNFVUluWnJhSmFaU292Y01FektZTGt CVkRvRzBqOUhwTWkyQmVvSjNoMGVKY3JOaWhnT1dYeVQzcHpQVUNJc2hkbTVHWTFDT0pDNjRvSzBBUVZ JelVnQlFxS3VqQW52VGZ0VWcwdnFCVHRIRXhPTQ/messages/@original' }

Node.js v18.3.0

jonathonor commented 1 year ago

Ok I see. It appears that the bot only has 15 minutes to reply to the command. So if it's taking longer than that I'll need to send the message a different way.

Is this happening on the role-checker analyze option? Or force-sync?

zacharytbaldino commented 1 year ago

It happens on both options same error.

jonathonor commented 1 year ago

Ok, I think I know how I'll fix it.

jonathonor commented 1 year ago

I should have time to fix it Monday.

zacharytbaldino commented 1 year ago

Take your time, sorry to throw all these issues at you

jonathonor commented 1 year ago

No worries! I'm happy to help, and it makes the bot better for others who use it in the future!

zacharytbaldino commented 1 year ago

Just wanted to throw this in here also, It looks like some of the errors that the console is throwing are related to something on our end as our backup server does not share roles as we have added some new roles

jonathonor commented 1 year ago

No worries, I made some progress on fixes yesterday and am trying to wrap them up today, then I'll let you test them for me 🙂

jonathonor commented 1 year ago

@zacharytbaldino Ok, I pushed an update that should allow the bot to process as many members as your guild has. Please run the role-checker with analyze option and report back if it works!

zacharytbaldino commented 1 year ago

Just ran the command and it didn't throw any errors out of the norm, however I have not tested the force-sync function. I know before the update it ran just as an analyze and didn't update roles.

jonathonor commented 1 year ago

Please verify that the functionality works as you expect and we can close this issue.

jonathonor commented 1 year ago

Closing since no additional response was made after assumed fix was implemented.