Rowan.
Rowan.
DIAdiscord.js - Imagine an app
Created by Rowan. on 8/14/2023 in #djs-questions
I get an error about the interaction
Im trying to make my first discord bot. Currently ive got this // commands/ping.js module.exports = { data: { name: 'ping', description: 'Ping command.', }, async execute(interaction) { interaction.deferReply(); console.log(interaction.commandName) console.log(interaction.deferred) setTimeout(() => { interaction.followUp('Pong!'); }, 4000); }, }; My commands/ping.js require('dotenv').config(); const {Client, IntentsBitField} = require('discord.js'); const Discord = require('discord.js'); const fs = require('fs'); const {configDotenv} = require("dotenv"); const client = new Client({ intents: [ IntentsBitField.Flags.Guilds, IntentsBitField.Flags.GuildMessages, IntentsBitField.Flags.GuildMessageReactions, IntentsBitField.Flags.MessageContent, ], }); // Load interaction commands dynamically from the "interactions" directory const interactionFiles = fs.readdirSync('./src/commands').filter(file => file.endsWith('.js')); const interactions = new Map(); for (const file of interactionFiles) { const interaction = require(./commands/${file}); interactions.set(interaction.data.name, interaction); } client.once('ready', () => { console.log(Logged in as ${client.user.tag}!); console.log(process.env.CLIENT_ID) }); client.on('interactionCreate', async interaction => { if (!interaction.isCommand()) return; const { commandName } = interaction; const command = interactions.get(commandName); if (!command) return; try { await command.execute(interaction); } catch (error) { console.error(error); await interaction.reply({ content: 'An error occurred while executing the command.', ephemeral: true }); } }); client.login(process.env.TOKEN); And my index.JS When i run this from my pc it works perfectly but once ive dockerized it and put it on portainer to run from my server i get an error.
11 replies