Jereme
DIAdiscord.js - Imagine an app
•Created by Jereme on 6/25/2024 in #djs-questions
Hello sorry im new to this but did i do this right
const { Client, Intents } = require('discord.js');
require('dotenv').config();
const client = new Client({
intents: [
Intents.FLAGS.GUILDS, // Allows the bot to interact with guilds (servers)
Intents.FLAGS.GUILD_MESSAGES
]
});
client.commands = new Map();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
client.once('ready', () => {
console.log('Bot is ready!');
client.user.setPresence({
activities: [{ name: 'd', type: 'PLAYING' }],
status: 'online',
});
const guildId = '1254264050658054204';
client.guilds.cache.get(guildId)?.commands.set(Array.from(client.commands.values())).then(() => {
console.log('Slash commands registered!');
}).catch(console.error);
});
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
const { commandName } = interaction;
if (!client.commands.has(commandName)) return;
try {
await client.commands.get(commandName).execute(interaction);
} catch (error) {
console.error(error);
await interaction.reply({ content: 'There was an error executing this command.', ephemeral: true });
}
});
client.login(process.env.DISCORD_TOKEN);
const { Client, Intents } = require('discord.js');
require('dotenv').config();
const client = new Client({
intents: [
Intents.FLAGS.GUILDS, // Allows the bot to interact with guilds (servers)
Intents.FLAGS.GUILD_MESSAGES
]
});
client.commands = new Map();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
client.once('ready', () => {
console.log('Bot is ready!');
client.user.setPresence({
activities: [{ name: 'd', type: 'PLAYING' }],
status: 'online',
});
const guildId = '1254264050658054204';
client.guilds.cache.get(guildId)?.commands.set(Array.from(client.commands.values())).then(() => {
console.log('Slash commands registered!');
}).catch(console.error);
});
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
const { commandName } = interaction;
if (!client.commands.has(commandName)) return;
try {
await client.commands.get(commandName).execute(interaction);
} catch (error) {
console.error(error);
await interaction.reply({ content: 'There was an error executing this command.', ephemeral: true });
}
});
client.login(process.env.DISCORD_TOKEN);
101 replies
DIAdiscord.js - Imagine an app
•Created by Jereme on 3/25/2024 in #djs-questions
i need code help
pm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /home/container/node_modules/debug
npm ERR! dest /home/container/node_modules/.debug-94G7iWjh
npm ERR! errno -39
npm ERR! ENOTEMPTY: directory not empty, rename '/home/container/node_modules/debug' -> '/home/container/node_modules/.debug-94G7iWjh'
npm ERR! A complete log of this run can be found in: /home/container/.npm/_logs/2024-03-25T02_09_34_146Z-debug-0.log
Error: Cannot find module 'express'
Require stack:
- /home/container/src/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/src/index.js:1:13)
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/src/index.js' ]
pm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /home/container/node_modules/debug
npm ERR! dest /home/container/node_modules/.debug-94G7iWjh
npm ERR! errno -39
npm ERR! ENOTEMPTY: directory not empty, rename '/home/container/node_modules/debug' -> '/home/container/node_modules/.debug-94G7iWjh'
npm ERR! A complete log of this run can be found in: /home/container/.npm/_logs/2024-03-25T02_09_34_146Z-debug-0.log
Error: Cannot find module 'express'
Require stack:
- /home/container/src/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/src/index.js:1:13)
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/src/index.js' ]
10 replies
DIAdiscord.js - Imagine an app
•Created by Jereme on 3/2/2024 in #djs-questions
DM messages not being received properly
it dont work
186 replies