Giter Site home page Giter Site logo

jonathonor / syncbot Goto Github PK

View Code? Open in Web Editor NEW
27.0 6.0 16.0 364 KB

A bot that syncs roles between multiple discord servers.

Home Page: https://www.jonsbots.com/syncBot

JavaScript 100.00%
discord discord-bot discord-js role sync reverse multiple roles roles-management server

syncbot's People

Contributors

jonathonor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

syncbot's Issues

Bot crashes if it lacks permission to assign a role on target server(s)

DiscordAPIError[50013]: Missing Permissions
at SequentialHandler.runRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:933:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.queueRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:712:14)
at async REST.request (/home/container/node_modules/@discordjs/rest/dist/index.js:1321:22)
at async GuildMemberRoleManager.add (/home/container/node_modules/discord.js/src/managers/GuildMemberRoleManager.js:131:7) {
rawError: { message: 'Missing Permissions', code: 50013 },
code: 50013,
status: 403,
method: 'PUT',
url: 'https://discord.com/api/v10/guilds/1067429100723118141/members/97026170465316864/roles/1067429100836376698',
requestBody: { files: undefined, json: undefined }
}

Getting it to run 24/7 and be automated.

Hello,

Sorry to bother you, but having trouble knowing how to get it to run 24/7 and also be automated so it does the role syncing it's self.

Help would be appreciated.
Thank you.

Sync Roles by IDs

Love this bot, it's the only thing of its kind doing this I can find, so thank you for creating it.

I'd like it to be possible to be able to map a source role to a target role (or roles) by ID, so it doesn't rely on name matching, and more importantly, doesn't try to apply every role it can find by name match.

Role checker analyze does not fix mismatches in roles

Describe the bug
I have 2 servers, 1 main and 1 secondary.
At one time 1 saw that there where a few ( i think 3 ) people that had a special role in the secondary server and not in the main server because they lost the role on the main server.

However it stays unclear how the bot didnt sync the roles, they should be removed..
So i did a analyze to find more people.
The analyze was run, but it didnt sync or fix the problem.
It didnt saw the persons with the special role in the secondary server.. therefor not removing it.

Most of the time the sync bot just works.. but this was a rather strange thing. and still i cant fix this and need to remove the role myself

The syncbot is on top of the role section.. and no errors are in the logs that indicates something is wrong.

To Reproduce
Steps to reproduce the behavior:

  1. have 1 person in both servers
  2. Give person in server 1 the role, it will be synct to server 2
  3. remove role from person in server 1,
  4. role doesnt get deleted from person in server 2..
  5. maybe bot was offline altough it has been stable who knows.. so we do an analyze.
  6. bot does the analyze if there are errors.
  7. it does not see that the person has special role in server 2 and not in 1 anymore.. so it leaves the role on the person

Expected behavior
An analyze should see that there is something wrong or not in sync and fix the roles.

Additional context
Remember this is hard to reproduce..
the only way for me to reproduce is..

give the person a role in server 2 that it does not have anymore in server 1.
And see what the bot does with it..
Analyze should fix it, but does not.

Errors when trying to use any command

Hello! First of all thank you for your work, it's exactly what I've been looking for for a while! I have an error, however, when I run the command "node register.js" on my shared hosting (which supports nodejs apps). Here is the output of that command:

[bots/syncbot (16)] [####@delaware syncbot]$ node register.js
Started refreshing application (/) commands.
TypeError: Cannot destructure property 'exports' of 'undefined' as it is undefined.
    at new Parser (/home/####/bots/syncbot/node_modules/undici/lib/client.js:405:34)
    at connect (/home/####/bots/syncbot/node_modules/undici/lib/client.js:1062:23)
/home/####/bots/syncbot/node_modules/undici/lib/client.js:1167
        if (socket[kParser].timeoutType !== TIMEOUT_IDLE) {
                            ^

TypeError: Cannot read properties of undefined (reading 'timeoutType')
    at _resume (/home/####/bots/syncbot/node_modules/undici/lib/client.js:1167:29)
    at resume (/home/####/bots/syncbot/node_modules/undici/lib/client.js:1131:3)
    at connect (/home/####/bots/syncbot/node_modules/undici/lib/client.js:1116:3)

I'm very newbie to nodejs, I have no idea what any of this means haha. I really hope you can help me. Thank you again!

TypeError: client.guilds.find is not a function

C:\Bots\syncBot\run.js:52
const guild1 = client.guilds.find(guild => guild.id === config.server1id);
^

TypeError: client.guilds.find is not a function
at Timeout.setTimeout [as _onTimeout] (C:\Bots\syncBot\run.js:52:42)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)

package.json missing

The ability to run a command that will force the bot to check all users with the role in the main server and ensure they have the proper role in the other discords. A flag to remove anyone with the role in other discords that does have it in the main discord would be a great feature

Not able to register the bot.

Screenshot 2022-04-15 at 11 47 16 PM
I tried running "node register.js" but got the error. I've made sure everything is fine and I have even set up config.json properly.

Bot is offline

Hello there,
the bot doesnt really work, because he is offline,
did i do something wrong?

Is this correct, how i did fill it in?
"token": "OTQxMjg5MDYwNTkxMzUzODc2.YgTxwA.Fc5_F0w6d9EzaZ2DUqyhyAFsiFg", "clientId": "941289060591353876", "mainServer": "724366785993768991", "syncedServers": "824542691882303500", "commanderRole": "●Ely | eSports","●Ely | Academy", "logChannelId": "901818092395561021 }

Uncaught DiscordAPIError: Missing Access

I was testing your bot and I came across an error saying "Uncaught DiscordAPIError: Missing Access
No debugger available, can not send 'variables'". I checked the role hierarchy, name, and nothing resolved

Bot shuts down when this error appears. Could you tell me what's causing this?

DiscordAPIError[10011]: Unknown Role
at SequentialHandler.runRequest (C:\ReverseSync\syncBot\node_modules@discordjs\rest\dist\index.js:667:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.queueRequest (C:\ReverseSync\syncBot\node_modules@discordjs\rest\dist\index.js:464:14)
at async REST.request (C:\ReverseSync\syncBot\node_modules@discordjs\rest\dist\index.js:910:22)
at async GuildMemberRoleManager.remove (C:\ReverseSync\syncBot\node_modules\discord.js\src\managers\GuildMemberRoleManager.js:168:7) {
requestBody: { files: undefined, json: undefined },
rawError: { message: 'Unknown Role', code: 10011 },
code: 10011,
status: 404,
method: 'DELETE',
url: 'https://discord.com/api/v10/guilds/929969152356155435/members/656621136808902656/roles/934472142404321311'
}
node:events:491
throw er; // Unhandled 'error' event
^

TypeError: Cannot read properties of undefined (reading 'id')
at Client. (file:///C:/ReverseSync/syncBot/runReverse.js:321:76)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21)

Feature request

Would it be possible to make it so that the roles that I specify are automatically added the moment it's been added to the user?

For example,

Main Server Role 1 and Server 2 Role 1 are synced.

Bot gives Role 1 to the user in the main server automatically.

The user gets Role 1 in the server 2 also without the use of /add command.

Reverse

I would like to know if there is the possibility of doing the reverse, instead of looking for roles on the main server, looking for sync servers to add to the main server.

Example, if a member has role1 on one of the 10 sync servers, the bot adds role1 to the member on the main server.

Bot can't start (first install)

Describe the bug
Bot can't start (first install)

To Reproduce
Steps to reproduce the behavior:
run run.js

Log
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@discordjs/[email protected]',
npm WARN EBADENGINE required: { node: '>=16.9.0' },
npm WARN EBADENGINE current: { node: 'v16.6.1', npm: '7.20.3' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@discordjs/[email protected]',
npm WARN EBADENGINE required: { node: '>=16.9.0' },
npm WARN EBADENGINE current: { node: 'v16.6.1', npm: '7.20.3' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@discordjs/[email protected]',
npm WARN EBADENGINE required: { node: '>=16.9.0' },
npm WARN EBADENGINE current: { node: 'v16.6.1', npm: '7.20.3' }
npm WARN EBADENGINE }

up to date, audited 56 packages in 1s
14 packages are looking for funding
run npm fund for details
found 0 vulnerabilities
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@discordjs/[email protected]',
npm WARN EBADENGINE required: { node: '>=16.9.0' },
npm WARN EBADENGINE current: { node: 'v16.6.1', npm: '7.20.3' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@discordjs/[email protected]',
npm WARN EBADENGINE required: { node: '>=16.9.0' },
npm WARN EBADENGINE current: { node: 'v16.6.1', npm: '7.20.3' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@discordjs/[email protected]',
npm WARN EBADENGINE required: { node: '>=16.9.0' },
npm WARN EBADENGINE current: { node: 'v16.6.1', npm: '7.20.3' }
npm WARN EBADENGINE }

up to date, audited 56 packages in 541ms
14 packages are looking for funding
run npm fund for details
found 0 vulnerabilities
file:///home/container/run.js:17
Client, GatewayIntentBits
^^^^^^^^^^^^^^^^^
SyntaxError: The requested module 'discord.js' does not provide an export named 'GatewayIntentBits'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:179:5)
at async Loader.import (node:internal/modules/esm/loader:178:24)
at async Object.loadESM (node:internal/process/esm_loader:68:5)
at async handleMainPromise (node:internal/modules/run_main:63:12)

sync roles request

ability to sync roles on MAINSERVER based on what server the person is in out of a list of 15 other servers...

this would help sort members on a specific team thats located in the 'main hub'

[Reverse Sync] It keeps on crushing for some reason and I don't know how to recreate it

Last login: Mon Jan 30 12:02:10 2023 from 77.170.110.167
tmroot@somethingcp-11003:~# tmux a -t DLSync
1 true true
1 true true
1 true true
1 true true
TypeError [InvalidType]: Supplied roles is not a Role, Snowflake or Array or Collection of Roles or Snowflakes.
at GuildMemberRoleManager.add (/root/DLSync/node_modules/discord.js/src/managers/GuildMemberRoleManager.js:124:15)
at file:///root/DLSync/runReverse.js:262:14
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
code: 'InvalidType'
}
1 true true
1 true true
1 true true
1 true true
1 true false
1 true false
node:events:491
throw er; // Unhandled 'error' event
^

DiscordAPIError[10007]: Unknown Member
at SequentialHandler.runRequest (/root/DLSync/node_modules/@discordjs/rest/dist/index.js:667:15)
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async SequentialHandler.queueRequest (/root/DLSync/node_modules/@discordjs/rest/dist/index.js:464:14)
at async REST.request (/root/DLSync/node_modules/@discordjs/rest/dist/index.js:910:22)
at async GuildMemberManager._fetchSingle (/root/DLSync/node_modules/discord.js/src/managers/GuildMemberManager.js:489:18)
at async Client. (file:///root/DLSync/runReverse.js:420:26)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)
at processTicksAndRejections (node:internal/process/task_queues:85:21) {
requestBody: { files: undefined, json: undefined },
rawError: { message: 'Unknown Member', code: 10007 },
code: 10007,
status: 404,
method: 'GET',
url: 'https://discord.com/api/v10/guilds/929969469558751262/members/1069428375422251009'
}
root@somethingcp-11003:/DLSync# node:events:491
node:events:491: command not found
root@somethingcp-11003:
/DLSync# throw er; // Unhandled 'error' event
throw: command not found
-bash: //: Is a directory
root@somethingcp-11003:/DLSync# ^
^: command not found
root@somethingcp-11003:
/DLSync#
root@somethingcp-11003:/DLSync# TypeError: Cannot read properties of undefined (reading 'remove')
-bash: syntax error near unexpected token (' root@somethingcp-11003:~/DLSync# at Client.<anonymous> (file:///root/DLSync/runReverse.js:471:12) -bash: syntax error near unexpected token ('
root@somethingcp-11003:
/DLSync# at processTicksAndRejections (node:internal/process/task_queues:96:5)
-bash: syntax error near unexpected token (' root@somethingcp-11003:~/DLSync# Emitted 'error' event on Client instance at: Emitted: command not found root@somethingcp-11003:~/DLSync# at emitUnhandledRejectionOrErr (node:events:394:10) -bash: syntax error near unexpected token ('
root@somethingcp-11003:/DLSync# at processTicksAndRejections (node:internal/process/task_queues:85:21)
-bash: syntax error near unexpected token `('
root@somethingcp-11003:
/DLSync# root@somethingcp-11003:~/DLSync# node r

v12

Are you going to update the bot to v12?

Issue when running /role-checker force-sync command

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

[Reverse] Bot is crashing and I don't know how to recreate it

Hello, my apologies for late report, I haven't had the time to check it. However, it seems like the bot isn't working or crashing everytime.

`node:events:491
throw er; // Unhandled 'error' event
^

TypeError: Cannot read properties of undefined (reading 'remove')
at Client. (file:///root/DLSync/runReverse.js:497:14)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)
at processTicksAndRejections (node:internal/process/task_queues:85:21)
root@somethingcp-11003:/DLSync# node registerGlobal.js
Started refreshing application (/) commands.
Successfully reloaded application (/) commands.
root@somethingcp-11003:
/DLSync# node runReverse.js
syncbot ready!
GUILDMEMBERADD_MEMBER_FETCH Error: DiscordAPIError[10007]: Unknown Member
GUILDMEMBERADD_MEMBER_FETCH Error: DiscordAPIError[10007]: Unknown Member
GUILDMEMBERADD_MEMBER_FETCH Error: DiscordAPIError[10007]: Unknown Member
GUILDMEMBERADD_MEMBER_FETCH Error: DiscordAPIError[10007]: Unknown Member
GUILDMEMBERADD_MEMBER_FETCH Error: DiscordAPIError[10007]: Unknown Member
GUILDMEMBERADD_MEMBER_FETCH Error: DiscordAPIError[10007]: Unknown Member
GUILDMEMBERADD_MEMBER_FETCH Error: DiscordAPIError[10007]: Unknown Member
node:events:491
throw er; // Unhandled 'error' event
^

TypeError: Cannot read properties of undefined (reading 'remove')
at Client. (file:///root/DLSync/runReverse.js:497:14)
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)
at processTicksAndRejections (node:internal/process/task_queues:85:21)
root@somethingcp-11003:/DLSync# node registerGlobal.js
Started refreshing application (/) commands.
Successfully reloaded application (/) commands.
root@somethingcp-11003:
/DLSync# node runReverse.js
syncbot ready!
Unable to apply action: roleAnalyze to Patreon. Member is a bot.
Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
at ChatInputCommandInteraction.deferReply (/root/DLSync/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:67:46)
at roleAnalyze (file:///root/DLSync/runReverse.js:102:21)
at file:///root/DLSync/helpers.js:15:26
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
code: 'InteractionAlreadyReplied'
}
exit
`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.