rubii
rubii
DIAdiscord.js - Imagine an app
Created by rubii on 8/2/2024 in #djs-questions
Cannot create permissionOverwrites for users with server booster
Hi, I implement some manual "mute" action for my bot (so that the user can see the channels, can't message but can interact with the bot), and for that I used permissionOverwrites like this:
await channel.permissionOverwrites.create(offender.id,
{ 'SendMessages': false,
'SendMessagesInThreads': false,
'SendVoiceMessages': false,
'CreatePublicThreads': false,
'CreatePrivateThreads': false,
});
await channel.permissionOverwrites.create(offender.id,
{ 'SendMessages': false,
'SendMessagesInThreads': false,
'SendVoiceMessages': false,
'CreatePublicThreads': false,
'CreatePrivateThreads': false,
});
But this doesn't work for users with "server booster" role because as I understand, this role is handled by Discord. So this code would give DiscordAPIError[50013]: Missing Permissions. But still, I just want to "mute" them. I searched on Google but I can only find the problem, not the solution. Is there actually any possible solution? Thank you so much!
18 replies
DIAdiscord.js - Imagine an app
Created by rubii on 6/27/2024 in #djs-questions
Permission needed for permissionOverwrite method
Hi, I'm developing a bot for my server, so I let it have Admin permission. However I want my friend test my bot as well, but he doesn't want a bot with Admin, so I'm figuring out what permission I need for my bot to operate. I tried checking all the permission but admin, and I got this error:
./node_modules/@discordjs/rest/dist/index.js:722
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^

DiscordAPIError[50001]: Missing Access
at handleErrors (./node_modules/@discordjs/rest/dist/index.js:722:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (./node_modules/@discordjs/rest/dist/index.js:1120:23)
at async SequentialHandler.queueRequest (./node_modules/@discordjs/rest/dist/index.js:953:14)
at async _REST.request (./node_modules/@discordjs/rest/dist/index.js:1266:22)
at async PermissionOverwriteManager.upsert (./node_modules/discord.js/src/managers/PermissionOverwriteManager.js:107:5)
at async ./commands/mute.js:134:13 {
requestBody: {
files: undefined,
json: {
id: '767335568647782441',
type: 1,
allow: PermissionsBitField { bitfield: 0n },
deny: PermissionsBitField { bitfield: 70643622086656n }
}
},
rawError: { message: 'Missing Access', code: 50001 },
code: 50001,
status: 403,
method: 'PUT',
url: 'https://discord.com/api/v10/channels/1203231726688538635/permissions/767335568647782441'
}

Node.js v18.16.0
./node_modules/@discordjs/rest/dist/index.js:722
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^

DiscordAPIError[50001]: Missing Access
at handleErrors (./node_modules/@discordjs/rest/dist/index.js:722:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (./node_modules/@discordjs/rest/dist/index.js:1120:23)
at async SequentialHandler.queueRequest (./node_modules/@discordjs/rest/dist/index.js:953:14)
at async _REST.request (./node_modules/@discordjs/rest/dist/index.js:1266:22)
at async PermissionOverwriteManager.upsert (./node_modules/discord.js/src/managers/PermissionOverwriteManager.js:107:5)
at async ./commands/mute.js:134:13 {
requestBody: {
files: undefined,
json: {
id: '767335568647782441',
type: 1,
allow: PermissionsBitField { bitfield: 0n },
deny: PermissionsBitField { bitfield: 70643622086656n }
}
},
rawError: { message: 'Missing Access', code: 50001 },
code: 50001,
status: 403,
method: 'PUT',
url: 'https://discord.com/api/v10/channels/1203231726688538635/permissions/767335568647782441'
}

Node.js v18.16.0
In my code, I have a custom mute command that changes the user's permission so they just cannot send messages, which I used "channel.permissionOverwrites.create(...)", but then this line caused the error. But it didn't have this error when I gave it admin permission. Is there any way to prevent this without granting it admin perm? P/s: In my OAuth2, I set the scope to application.commands & bot, and all permissions except admin.
17 replies
DIAdiscord.js - Imagine an app
Created by rubii on 2/20/2024 in #djs-questions
Error - Opening handshake timed out
My bot was running okay locally until recently it sometimes raises the timed out error when I tried re-running the code. The error goes like this:
.../node_modules/ws/lib/websocket.js:856
abortHandshake(websocket, req, 'Opening handshake has timed out');
^

Error: Opening handshake has timed out
.../node_modules/ws/lib/websocket.js:856
abortHandshake(websocket, req, 'Opening handshake has timed out');
^

Error: Opening handshake has timed out
Sometimes all I need to do is just restart (re-running the command) several times until it works normal again. Why does this happen and how I can fix it?
4 replies