Ypsilon
Ypsilon
DIAdiscord.js - Imagine an app
Created by Ypsilon on 10/7/2023 in #djs-questions
Embed Thumbnail not showing
No description
9 replies
DIAdiscord.js - Imagine an app
Created by Ypsilon on 8/28/2022 in #djs-questions
Import all commands from folder with ES modules
So my previous bot I build I used CommonJS and did the commands like this:
const commandsList = [];
const slashCommandFiles = readdirSync(path.resolve(__dirname, '../discord/commands'));

for (const fileSlash of slashCommandFiles) {
const commandSlash = require(path.resolve(__dirname, `../discord/commands/${fileSlash}`));
commandsList.push(commandSlash.commands)
}
const commandsList = [];
const slashCommandFiles = readdirSync(path.resolve(__dirname, '../discord/commands'));

for (const fileSlash of slashCommandFiles) {
const commandSlash = require(path.resolve(__dirname, `../discord/commands/${fileSlash}`));
commandsList.push(commandSlash.commands)
}
But now I really prefer to work with ES modules also because they are by default async. But now I have been thinking about a way to import all commands from the folder. But it doesn't work that easy with import. Anyone know a good way to do this. Because the export where build like
{
data: blabla,
action: (arg) => { stuff }
}
{
data: blabla,
action: (arg) => { stuff }
}
17 replies
DIAdiscord.js - Imagine an app
Created by Ypsilon on 8/22/2022 in #djs-questions
Can't get permissions on interaction command working
So with a rest.put I enter the commands in the discord
name: 'getideas',
description: 'get the list of ideas',
defaultMemberPermissions: 'Administrator',
name: 'getideas',
description: 'get the list of ideas',
defaultMemberPermissions: 'Administrator',
I have tried
defaultMemberPermissions: 'ADMINISTRATOR',
defaultMemberPermissions: 'ADMINISTRATOR',
defaultMemberPermissions: '0x0000000000000008',
defaultMemberPermissions: '0x0000000000000008',
defaultMemberPermissions: 'PermissionsBitField.Flags.Administrator',
defaultMemberPermissions: 'PermissionsBitField.Flags.Administrator',
The last one complains that it can serialize with the stringify for the put request None of these work. people without adminstrator rights keep seeing the command wrong. What am I doing wrong here ?
4 replies