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: [] }
}
13 Replies
d.js toolkit
d.js toolkitβ€’4mo 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
AC / LogicTubes_Boss πŸ‡ΈπŸ‡¦
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"
]
}
d.js docs
d.js docsβ€’4mo ago
_Suggestion for @AC / LogicTubesBoss πŸ‡ΈπŸ‡¦: :guide: Slash Commands: Slash command permissions read more
Unknown User
Unknown Userβ€’4mo ago
Message Not Public
Sign In & Join Server To View
AC / LogicTubes_Boss πŸ‡ΈπŸ‡¦
I got that code from another programmer have more experience than me
Unknown User
Unknown Userβ€’4mo ago
Message Not Public
Sign In & Join Server To View
AC / LogicTubes_Boss πŸ‡ΈπŸ‡¦
the general idea
Unknown User
Unknown Userβ€’4mo ago
Message Not Public
Sign In & Join Server To View
AC / LogicTubes_Boss πŸ‡ΈπŸ‡¦
he says it's on old version
Unknown User
Unknown Userβ€’4mo ago
Message Not Public
Sign In & Join Server To View
AC / LogicTubes_Boss πŸ‡ΈπŸ‡¦
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
Unknown User
Unknown Userβ€’4mo ago
Message Not Public
Sign In & Join Server To View
AC / LogicTubes_Boss πŸ‡ΈπŸ‡¦
i'll much love ❀️