Virgile
DIAdiscord.js - Imagine an app
•Created by Virgile on 7/13/2023 in #djs-questions
how to verify if the DM of an user is open/close?
I make a modmail bot, but I don't find how to check if a DM is open or close. Is there a method to do that ? thx
3 replies
DIAdiscord.js - Imagine an app
•Created by Virgile on 6/14/2023 in #djs-questions
MemberRemove call when I kick my bot
When I kick my bot of a server, I think that the event "MemberRemive" is called, and it makes a bug :
That's possible ? If yes how to fix it
thx
node_modules\@discordjs\rest\dist\index.js:640
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^
DiscordAPIError[50013]: Missing Permissions
node_modules\@discordjs\rest\dist\index.js:640
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^
DiscordAPIError[50013]: Missing Permissions
54 replies
DIAdiscord.js - Imagine an app
•Created by Virgile on 1/23/2023 in #djs-questions
deploy commands folder
I'm trying to change the basic "deploy commands" that you give to us. I want to be able to read subfolder with files in the folder "commands"
I did that :
But it gives me that error :
`
I don't understand what's wrong.
const { REST, Routes } = require('discord.js');
const { clientId, guildId, token } = require('./config.json');
const fs = require('node:fs');
const path = require('node:path');
const commandsPath = './commands';
const commands = [];
function readDirectory(dir) {
const files = fs.readdirSync(dir);
for (const file of files) {
const filePath = path.join(dir, file);
const stats = fs.statSync(filePath);
if (stats.isFile() && file.endsWith('.js')) {
try {
const command = require(filePath);
if ('data' in command && 'execute' in command) {
commands.push(command.data.toJSON());
} else {
throw new Error(`Command at ${filePath} is missing required "data" or "execute" property.`);
}
} catch (error) {
console.error(`[ERROR] Failed to load command from ${filePath}: ${error}`);
}
} else if (stats.isDirectory()) {
readDirectory(filePath);
}
}
}
readDirectory(commandsPath);
// Construct and prepare an instance of the REST module
const rest = new REST({ version: '10' }).setToken(token);
(async () => {
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);
// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
);
console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
// And of course, make sure you catch and log any errors!
console.error(error);
}
})();
const { REST, Routes } = require('discord.js');
const { clientId, guildId, token } = require('./config.json');
const fs = require('node:fs');
const path = require('node:path');
const commandsPath = './commands';
const commands = [];
function readDirectory(dir) {
const files = fs.readdirSync(dir);
for (const file of files) {
const filePath = path.join(dir, file);
const stats = fs.statSync(filePath);
if (stats.isFile() && file.endsWith('.js')) {
try {
const command = require(filePath);
if ('data' in command && 'execute' in command) {
commands.push(command.data.toJSON());
} else {
throw new Error(`Command at ${filePath} is missing required "data" or "execute" property.`);
}
} catch (error) {
console.error(`[ERROR] Failed to load command from ${filePath}: ${error}`);
}
} else if (stats.isDirectory()) {
readDirectory(filePath);
}
}
}
readDirectory(commandsPath);
// Construct and prepare an instance of the REST module
const rest = new REST({ version: '10' }).setToken(token);
(async () => {
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);
// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
);
console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
// And of course, make sure you catch and log any errors!
console.error(error);
}
})();
[ERROR] Failed to load command from commands\ban\ban.js: Error: Cannot find module 'commands\ban\ban.js'
Require stack:
- c:\Users\virgi\OneDrive\Documents\Projets perso\progra\js\bots-altara\Thenix - Modération\deploy-commands.js
[ERROR] Failed to load command from commands\ban\unban.js: Error: Cannot find module 'commands\ban\unban.js'
Require stack:
- c:\Users\virgi\OneDrive\Documents\Projets perso\progra\js\bots-altara\Thenix - Modération\deploy-commands.js
[ERROR] Failed to load command from commands\kick.js: Error: Cannot find module 'commands\kick.js'
Require stack:
- c:\Users\virgi\OneDrive\Documents\Projets perso\progra\js\bots-altara\Thenix - Modération\deploy-commands.js
[ERROR] Failed to load command from commands\mute\mute.js: Error: Cannot find module 'commands\mute\mute.js'
Require stack:
- c:\Users\virgi\OneDrive\Documents\Projets perso\progra\js\bots-altara\Thenix - Modération\deploy-commands.js
[ERROR] Failed to load command from commands\mute\unmute.js: Error: Cannot find module 'commands\mute\unmute.js'
Require stack:
- c:\Users\virgi\OneDrive\Documents\Projets perso\progra\js\bots-altara\Thenix - Modération\deploy-commands.js
[ERROR] Failed to load command from commands\ping.js: Error: Cannot find module 'commands\ping.js'
Require stack:
- c:\Users\virgi\OneDrive\Documents\Projets perso\progra\js\bots-altara\Thenix - Modération\deploy-commands.js
Started refreshing 0 application (/) commands.
Successfully reloaded 0 application (/) commands.
[ERROR] Failed to load command from commands\ban\ban.js: Error: Cannot find module 'commands\ban\ban.js'
Require stack:
- c:\Users\virgi\OneDrive\Documents\Projets perso\progra\js\bots-altara\Thenix - Modération\deploy-commands.js
[ERROR] Failed to load command from commands\ban\unban.js: Error: Cannot find module 'commands\ban\unban.js'
Require stack:
- c:\Users\virgi\OneDrive\Documents\Projets perso\progra\js\bots-altara\Thenix - Modération\deploy-commands.js
[ERROR] Failed to load command from commands\kick.js: Error: Cannot find module 'commands\kick.js'
Require stack:
- c:\Users\virgi\OneDrive\Documents\Projets perso\progra\js\bots-altara\Thenix - Modération\deploy-commands.js
[ERROR] Failed to load command from commands\mute\mute.js: Error: Cannot find module 'commands\mute\mute.js'
Require stack:
- c:\Users\virgi\OneDrive\Documents\Projets perso\progra\js\bots-altara\Thenix - Modération\deploy-commands.js
[ERROR] Failed to load command from commands\mute\unmute.js: Error: Cannot find module 'commands\mute\unmute.js'
Require stack:
- c:\Users\virgi\OneDrive\Documents\Projets perso\progra\js\bots-altara\Thenix - Modération\deploy-commands.js
[ERROR] Failed to load command from commands\ping.js: Error: Cannot find module 'commands\ping.js'
Require stack:
- c:\Users\virgi\OneDrive\Documents\Projets perso\progra\js\bots-altara\Thenix - Modération\deploy-commands.js
Started refreshing 0 application (/) commands.
Successfully reloaded 0 application (/) commands.
3 replies
DIAdiscord.js - Imagine an app
•Created by Virgile on 1/23/2023 in #djs-questions
timeout permission
What is the name for timeout permission.
For example, to kick I get the permission like that :
But I don't find the permission to timeout
interaction.member.permissions.has([PermissionsBitField.Flags.KickMembers]
interaction.member.permissions.has([PermissionsBitField.Flags.KickMembers]
6 replies