AC / LogicTubes_Boss πŸ‡ΈπŸ‡¦
AC / LogicTubes_Boss πŸ‡ΈπŸ‡¦
Explore posts from servers
DIAdiscord.js - Imagine a bot
Created by AC / LogicTubes_Boss πŸ‡ΈπŸ‡¦ on 4/2/2024 in #djs-questions
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: [] }
}
19 replies
DIAdiscord.js - Imagine a bot
Created by AC / LogicTubes_Boss πŸ‡ΈπŸ‡¦ on 3/28/2024 in #djs-questions
No response from client
I don't know why and by the way the "Command" word printed is the on on the client.on('ready')..., not in the tickets_system slash command need help
47 replies
DIAdiscord.js - Imagine a bot
Created by AC / LogicTubes_Boss πŸ‡ΈπŸ‡¦ on 12/5/2023 in #djs-questions
What is the problem that when I run code and create new ticket
What is the problem that when I run code and create new ticket I got a ticket have the permissions I set perfectly but when I try another one I don't get the permissions Why?
2 replies
DIAdiscord.js - Imagine a bot
Created by AC / LogicTubes_Boss πŸ‡ΈπŸ‡¦ on 12/4/2023 in #djs-questions
how to disable button from client.on(Events.interactionCreate, interaction => {})
how to disable button from
client.on(Events.interactionCreate, interaction => {
...
});
client.on(Events.interactionCreate, interaction => {
...
});
for example the button have customId = "TicketGet" How to disable that button after clicked
5 replies
DIAdiscord.js - Imagine a bot
Created by AC / LogicTubes_Boss πŸ‡ΈπŸ‡¦ on 12/3/2023 in #djs-questions
How to create new tag in a discussion and how to get the id of any tag in the discussion to apply it
How to create new tag in a discussion and how to get the id of any tag in the discussion to apply it to the new post?
3 replies
DIAdiscord.js - Imagine a bot
Created by AC / LogicTubes_Boss πŸ‡ΈπŸ‡¦ on 12/3/2023 in #djs-questions
How to get user details and give him a role by his "User ID"
How to get user details and give him role by his "User ID" I tried a lot but not working
23 replies
DIAdiscord.js - Imagine a bot
Created by AC / LogicTubes_Boss πŸ‡ΈπŸ‡¦ on 12/2/2023 in #djs-questions
if (!field) throw new DiscordjsTypeError(ErrorCodes.ModalSubmitInteractionFieldNotFound, customI
I have this error and this my code in the pictures
21 replies