DIA
discord.js - Imagine an appAC / LogicTubes_Boss πŸ‡ΈπŸ‡¦

ERROR DISCPRDAPI

/Handlers/Commands.js
const { Client } = require("discord.js");
const { GUILDID } = require("../../Structures/config.json");
const { Perms } = require("../Validations/Permissions");
/**
*
* @param {Client} client
*/
module.exports = async (client, PG, Ascii) => {
const Table = new Ascii("Commands Loaded");

let CommandsArray = [];

(await PG(`${process.cwd()}/Commands/**/*.js`)).map(async (file) => {
const command = require(file);

if (!command.name)
return Table.addRow(
`At ${file.split("/")[7]}`,
"πŸ”Έ FAILED",
`missing a name.`
);

if (!command.type && !command.description)
return Table.addRow(command.name, "πŸ”Έ FAILED", "missing a description.");

if (command.permission) {
if (Perms.includes(command.permission)) command.defaultPermission = false;
else
return Table.addRow(
command.name,
"πŸ”Έ FAILED",
`permission is invalid.`
);
}

client.commands.set(command.name, command);
CommandsArray.push(command);

await Table.addRow(command.name, "πŸ”Ή SUCCESSFUL");
});

console.log(Table.toString());

/// /// /// /// /// PERMISSIONS HANDLER /// /// /// /// ///

client.on("ready", async () => {
client.guilds.cache.forEach((g) => {
g.commands.set(CommandsArray).then(async (command) => {
const Roles = (commandName) => {
const cmdPerms = CommandsArray.find(
(c) => c.name === commandName
).permission;
if (!cmdPerms) return null;

return g.roles.cache
.filter((r) => r.permissions.has(cmdPerms) && !r.managed)
.first(10);
};

const fullPermissions = command.reduce((accumulator, r) => {
const roles = Roles(r.name);

if (!roles) return accumulator;

const permissions = roles.reduce((a, r) => {
return [
...a,
{
id: r.id,
type: "ROLE",
permission: true,
},
];
}, []);

return [
...accumulator,
{
id: r.id,
permissions,
},
];
}, []);

await g.commands.permissions.set({
fullPermissions,
});
});
});
});
};
const { Client } = require("discord.js");
const { GUILDID } = require("../../Structures/config.json");
const { Perms } = require("../Validations/Permissions");
/**
*
* @param {Client} client
*/
module.exports = async (client, PG, Ascii) => {
const Table = new Ascii("Commands Loaded");

let CommandsArray = [];

(await PG(`${process.cwd()}/Commands/**/*.js`)).map(async (file) => {
const command = require(file);

if (!command.name)
return Table.addRow(
`At ${file.split("/")[7]}`,
"πŸ”Έ FAILED",
`missing a name.`
);

if (!command.type && !command.description)
return Table.addRow(command.name, "πŸ”Έ FAILED", "missing a description.");

if (command.permission) {
if (Perms.includes(command.permission)) command.defaultPermission = false;
else
return Table.addRow(
command.name,
"πŸ”Έ FAILED",
`permission is invalid.`
);
}

client.commands.set(command.name, command);
CommandsArray.push(command);

await Table.addRow(command.name, "πŸ”Ή SUCCESSFUL");
});

console.log(Table.toString());

/// /// /// /// /// PERMISSIONS HANDLER /// /// /// /// ///

client.on("ready", async () => {
client.guilds.cache.forEach((g) => {
g.commands.set(CommandsArray).then(async (command) => {
const Roles = (commandName) => {
const cmdPerms = CommandsArray.find(
(c) => c.name === commandName
).permission;
if (!cmdPerms) return null;

return g.roles.cache
.filter((r) => r.permissions.has(cmdPerms) && !r.managed)
.first(10);
};

const fullPermissions = command.reduce((accumulator, r) => {
const roles = Roles(r.name);

if (!roles) return accumulator;

const permissions = roles.reduce((a, r) => {
return [
...a,
{
id: r.id,
type: "ROLE",
permission: true,
},
];
}, []);

return [
...accumulator,
{
id: r.id,
permissions,
},
];
}, []);

await g.commands.permissions.set({
fullPermissions,
});
});
});
});
};
Error:
/Users/suhayb/Downloads/LyxcodeTutorials-main/node_modules/discord.js/src/rest/RequestHandler.js:350
throw new DiscordAPIError(data, res.status, request);
^

DiscordAPIError: 405: Method Not Allowed
at RequestHandler.execute (/Users/suhayb/Downloads/LyxcodeTutorials-main/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async RequestHandler.push (/Users/suhayb/Downloads/LyxcodeTutorials-main/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
at async ApplicationCommandPermissionsManager.set (/Users/suhayb/Downloads/LyxcodeTutorials-main/node_modules/discord.js/src/managers/ApplicationCommandPermissionsManager.js:186:18)
at async /Users/suhayb/Downloads/LyxcodeTutorials-main/Structures/Handlers/Commands.js:85:9 {
method: 'put',
path: '/applications/1222688061410770985/guilds/1188858527746363473/commands/permissions',
code: 0,
httpStatus: 405,
requestData: { json: [], files: [] }
}
/Users/suhayb/Downloads/LyxcodeTutorials-main/node_modules/discord.js/src/rest/RequestHandler.js:350
throw new DiscordAPIError(data, res.status, request);
^

DiscordAPIError: 405: Method Not Allowed
at RequestHandler.execute (/Users/suhayb/Downloads/LyxcodeTutorials-main/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async RequestHandler.push (/Users/suhayb/Downloads/LyxcodeTutorials-main/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
at async ApplicationCommandPermissionsManager.set (/Users/suhayb/Downloads/LyxcodeTutorials-main/node_modules/discord.js/src/managers/ApplicationCommandPermissionsManager.js:186:18)
at async /Users/suhayb/Downloads/LyxcodeTutorials-main/Structures/Handlers/Commands.js:85:9 {
method: 'put',
path: '/applications/1222688061410770985/guilds/1188858527746363473/commands/permissions',
code: 0,
httpStatus: 405,
requestData: { json: [], files: [] }
}
DT
d.js toolkitβ€’18d ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - βœ… Marked as resolved by staff
AL
AC / LogicTubes_Boss πŸ‡ΈπŸ‡¦β€’18d ago
Permissions.js
module.exports = {
Perms: [
"CREATE_INSTANT_INVITE",
"KICK_MEMBERS",
"BAN_MEMBERS",
"ADMINISTRATOR",
"MANAGE_CHANNELS",
"MANAGE_GUILD",
"ADD_REACTIONS",
"VIEW_AUDIT_LOG",
"PRIORITY_SPEAKER",
"STREAM",
"VIEW_CHANNEL",
"SEND_MESSAGES",
"SEND_TTS_MESSAGES",
"MANAGE_MESSAGES",
"EMBED_LINKS",
"ATTACH_FILES",
"READ_MESSAGE_HISTORY",
"MENTION_EVERYONE",
"USE_EXTERNAL_EMOJIS",
"VIEW_GUILD_INSIGHTS",
"CONNECT",
"SPEAK",
"MUTE_MEMBERS",
"DEAFEN_MEMBERS",
"MOVE_MEMBERS",
"USE_VAD",
"CHANGE_NICKNAME",
"MANAGE_NICKNAMES",
"MANAGE_ROLES",
"MANAGE_WEBHOOKS",
"MANAGE_EMOJIS_AND_STICKERS",
"USE_APPLICATION_COMMANDS",
"REQUEST_TO_SPEAK",
"MANAGE_THREADS",
"USE_PUBLIC_THREADS",
"USE_PRIVATE_THREADS",
"USE_EXTERNAL_STICKERS"
]
}
module.exports = {
Perms: [
"CREATE_INSTANT_INVITE",
"KICK_MEMBERS",
"BAN_MEMBERS",
"ADMINISTRATOR",
"MANAGE_CHANNELS",
"MANAGE_GUILD",
"ADD_REACTIONS",
"VIEW_AUDIT_LOG",
"PRIORITY_SPEAKER",
"STREAM",
"VIEW_CHANNEL",
"SEND_MESSAGES",
"SEND_TTS_MESSAGES",
"MANAGE_MESSAGES",
"EMBED_LINKS",
"ATTACH_FILES",
"READ_MESSAGE_HISTORY",
"MENTION_EVERYONE",
"USE_EXTERNAL_EMOJIS",
"VIEW_GUILD_INSIGHTS",
"CONNECT",
"SPEAK",
"MUTE_MEMBERS",
"DEAFEN_MEMBERS",
"MOVE_MEMBERS",
"USE_VAD",
"CHANGE_NICKNAME",
"MANAGE_NICKNAMES",
"MANAGE_ROLES",
"MANAGE_WEBHOOKS",
"MANAGE_EMOJIS_AND_STICKERS",
"USE_APPLICATION_COMMANDS",
"REQUEST_TO_SPEAK",
"MANAGE_THREADS",
"USE_PUBLIC_THREADS",
"USE_PRIVATE_THREADS",
"USE_EXTERNAL_STICKERS"
]
}
DD
d.js docsβ€’18d ago
_Suggestion for @AC / LogicTubesBoss πŸ‡ΈπŸ‡¦: :guide: Slash Commands: Slash command permissions read more
UU
Unknown Userβ€’18d ago
AL
AC / LogicTubes_Boss πŸ‡ΈπŸ‡¦β€’18d ago
I got that code from another programmer have more experience than me
UU
Unknown Userβ€’18d ago
AL
AC / LogicTubes_Boss πŸ‡ΈπŸ‡¦β€’18d ago
the general idea
UU
Unknown Userβ€’18d ago
AL
AC / LogicTubes_Boss πŸ‡ΈπŸ‡¦β€’18d ago
he says it's on old version
UU
Unknown Userβ€’18d ago
AL
AC / LogicTubes_Boss πŸ‡ΈπŸ‡¦β€’18d ago
ok thank you so much yeah, I don't understand a lot of older versions because I'm new thank you anyway to tell me
UU
Unknown Userβ€’18d ago
AL
AC / LogicTubes_Boss πŸ‡ΈπŸ‡¦β€’18d ago
i'll much love ❀️
Want results from more Discord servers?
Add your server
More Posts
roleUpdate Logs Entires Roles List For A Small Change On One RoleWhenever I Change The Slightest Thing On A Role It Fires The Event And Logs ALL The Roles Is There Problem with Modal Buildersnode:events:497 throw er; // Unhandled 'error' event ^ DiscordAPIError[50035]: Invalid How to send files through broadcastEval?the error is due to an invalid file, the same does not happen when it is sent in the current client Unknown interaction, sometimesThe problem is that sometimes it works and sometimes it generates an error, and I've already tried iI need help with this errorcustom per-guild welcome messagehii, so i wish to make a customized welcome message system for each guild wherein users can customizEmbed and console desyncHello. Im trying to make a reaction role like system for my server. On startup it sends an embed on can anyone help me revise the set position command```ts setPosition(role: MockRole, position: number) { if (position < 0) position = 0; consApplication not responding errorI followed the steps in this website: https://discordjs.guide/creating-your-bot/#using-config-json, command handlermy code in 01registercommands.js ```const { testServer } = require('../../../config.json'); const arSend Embed to Channel with IDI would like to send my embed to a channel specified by ID. Unfortunately it doesn't work in my codeServer Deafen and Mutecan i remove the server deafen and server mute statuses from a user even if they aren't connected tofetch the new created channel```const { SlashCommandBuilder,PermissionFlagsBits } = require('discord.js'); module.exports = { Voice receiver doesn't pick up soundboard soundsI have a pretty fancy discord bot that uses a voice receiver to pick up audio from users. `const au12.5.3 Command not workingHeres my code, any idea why its not working? const Discord = require('discord.js'); const client =How this method works?How `client.application.commands.set()` works to deploy commands? and is an alternative for this? hHi everyone i have a question can anyone help me?How to set discord.js actually even though i read from the website i'm still confused i even watch sIn autocomplete, how can I get the value of an option type "User" ?Hello, I have a command ``unmute`` which have 2 options : - user (type: User) - mute-id (type: numbot status```let status = [ { name: 'death', type:ActivityType.Playing, }, { How to get never timeout buttonsI want my buttons in messages to get interactions forever. Even when I re-run the code, it must stil