Electrix
Electrix
DIAdiscord.js - Imagine an app
Created by Electrix on 2/9/2024 in #djs-questions
Reload command issue
Here is the code
6 replies
DIAdiscord.js - Imagine an app
Created by Electrix on 2/9/2024 in #djs-questions
Reload command issue
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, ModalBuilder, TextInputBuilder, TextInputStyle } = require('discord.js');
const config = require("../config.js")
module.exports = {
name: "reload",
description: "Admin command.",
options: [{
name: "command",
description: "The command to reload.",
type: 3,
required: true
}],
async execute(interaction) {
const commandName = interaction.options.getString('command', true).toLowerCase();
const command = interaction.client.commands.get(commandName);

if (!command) {
return interaction.reply(`There is no command with name \`${commandName}\`!`);
}

delete require.cache[require.resolve(`..commands/${command.data.name}.js`)];

try {
interaction.client.commands.delete(command.data.name);
const newCommand = require(`..commands/${command.data.name}.js`);
interaction.client.commands.set(newCommand.data.name, newCommand);
await interaction.reply(`Command \`${newCommand.data.name}\` was reloaded!`);
} catch (error) {
console.error(error);
await interaction.reply(`There was an error while reloading a command \`${command.data.name}\`:\n\`${error.message}\``);
}
},
};
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, ModalBuilder, TextInputBuilder, TextInputStyle } = require('discord.js');
const config = require("../config.js")
module.exports = {
name: "reload",
description: "Admin command.",
options: [{
name: "command",
description: "The command to reload.",
type: 3,
required: true
}],
async execute(interaction) {
const commandName = interaction.options.getString('command', true).toLowerCase();
const command = interaction.client.commands.get(commandName);

if (!command) {
return interaction.reply(`There is no command with name \`${commandName}\`!`);
}

delete require.cache[require.resolve(`..commands/${command.data.name}.js`)];

try {
interaction.client.commands.delete(command.data.name);
const newCommand = require(`..commands/${command.data.name}.js`);
interaction.client.commands.set(newCommand.data.name, newCommand);
await interaction.reply(`Command \`${newCommand.data.name}\` was reloaded!`);
} catch (error) {
console.error(error);
await interaction.reply(`There was an error while reloading a command \`${command.data.name}\`:\n\`${error.message}\``);
}
},
};
6 replies
DIAdiscord.js - Imagine an app
Created by Electrix on 1/30/2024 in #djs-questions
Trying to uninstall yt-dlp
Oh
6 replies
DIAdiscord.js - Imagine an app
Created by Electrix on 1/30/2024 in #djs-questions
Trying to uninstall yt-dlp
Of yeah sorry
6 replies
DIAdiscord.js - Imagine an app
Created by Electrix on 1/30/2024 in #djs-questions
Trying to uninstall yt-dlp
Error: Cannot find module '@distube/ytpl'
Require stack:
- /home/container/node_modules/distube/dist/index.js
- /home/container/bot.js
- /home/container/index.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (/usr/local/lib/node_modules/ts-node/node_modules/@cspotcode/source-map-support/source-map-support.js:811:30)
at Function.Module._load (node:internal/modules/cjs/loader:985:27)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at Object.<anonymous> (/home/container/node_modules/distube/src/core/DisTubeHandler.ts:1:18)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Object.require.extensions.<computed> [as .js] (/usr/local/lib/node_modules/ts-node/src/index.ts:1608:43)
at Module.load (node:internal/modules/cjs/loader:1207:32) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/container/node_modules/distube/dist/index.js',
'/home/container/bot.js',
'/home/container/index.js'
]
Error: Cannot find module '@distube/ytpl'
Require stack:
- /home/container/node_modules/distube/dist/index.js
- /home/container/bot.js
- /home/container/index.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (/usr/local/lib/node_modules/ts-node/node_modules/@cspotcode/source-map-support/source-map-support.js:811:30)
at Function.Module._load (node:internal/modules/cjs/loader:985:27)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at Object.<anonymous> (/home/container/node_modules/distube/src/core/DisTubeHandler.ts:1:18)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Object.require.extensions.<computed> [as .js] (/usr/local/lib/node_modules/ts-node/src/index.ts:1608:43)
at Module.load (node:internal/modules/cjs/loader:1207:32) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/container/node_modules/distube/dist/index.js',
'/home/container/bot.js',
'/home/container/index.js'
]
5 replies
DIAdiscord.js - Imagine an app
Created by Electrix on 1/30/2024 in #djs-questions
Trying to uninstall yt-dlp
• Discord.js : 14.6.0 • Node : v20.11.0
5 replies