nwqi
nwqi
DIAdiscord.js - Imagine an app
Created by nwqi on 1/11/2024 in #djs-questions
SyntaxError: Unexpected identifier 'Ready'
i expected it to be extremely simple
32 replies
DIAdiscord.js - Imagine an app
Created by nwqi on 1/11/2024 in #djs-questions
SyntaxError: Unexpected identifier 'Ready'
i understand but im not coding a bot. i literally just wanna have a single slash command that does nothing. so i thought i could do that first
32 replies
DIAdiscord.js - Imagine an app
Created by nwqi on 1/11/2024 in #djs-questions
SyntaxError: Unexpected identifier 'Ready'
can u help me fix it? idk what you mean
32 replies
DIAdiscord.js - Imagine an app
Created by nwqi on 1/11/2024 in #djs-questions
SyntaxError: Unexpected identifier 'Ready'
my first time coding
32 replies
DIAdiscord.js - Imagine an app
Created by nwqi on 1/11/2024 in #djs-questions
SyntaxError: Unexpected identifier 'Ready'
and thats my code (directly copied from the dicord.js guide)
32 replies
DIAdiscord.js - Imagine an app
Created by nwqi on 1/11/2024 in #djs-questions
SyntaxError: Unexpected identifier 'Ready'
No description
32 replies
DIAdiscord.js - Imagine an app
Created by nwqi on 1/11/2024 in #djs-questions
SyntaxError: Unexpected identifier 'Ready'
No description
32 replies
DIAdiscord.js - Imagine an app
Created by nwqi on 1/11/2024 in #djs-questions
SyntaxError: Unexpected identifier 'Ready'
im getting this error while trying to do node index.js
32 replies
DIAdiscord.js - Imagine an app
Created by nwqi on 1/11/2024 in #djs-questions
SyntaxError: Unexpected identifier 'Ready'
can yall help me?
32 replies
DIAdiscord.js - Imagine an app
Created by nwqi on 1/11/2024 in #djs-questions
SyntaxError: Unexpected identifier 'Ready'
Thank you and yes I was using chatgpt to help me lol
32 replies
DIAdiscord.js - Imagine an app
Created by nwqi on 1/11/2024 in #djs-questions
SyntaxError: Unexpected identifier 'Ready'
and every time i change stuff i get a new error very frustrating
32 replies
DIAdiscord.js - Imagine an app
Created by nwqi on 1/11/2024 in #djs-questions
SyntaxError: Unexpected identifier 'Ready'
ive been attempting this code for literall 5 hours
32 replies
DIAdiscord.js - Imagine an app
Created by nwqi on 1/11/2024 in #djs-questions
SyntaxError: Unexpected identifier 'Ready'
thank you:)
32 replies
DIAdiscord.js - Imagine an app
Created by nwqi on 1/11/2024 in #djs-questions
SyntaxError: Unexpected identifier 'Ready'
m first time coding
32 replies
DIAdiscord.js - Imagine an app
Created by nwqi on 1/11/2024 in #djs-questions
SyntaxError: Unexpected identifier 'Ready'
if some can help with all of it then that would be great
32 replies
DIAdiscord.js - Imagine an app
Created by nwqi on 1/11/2024 in #djs-questions
SyntaxError: Unexpected identifier 'Ready'
my whole code
32 replies
DIAdiscord.js - Imagine an app
Created by nwqi on 1/11/2024 in #djs-questions
SyntaxError: Unexpected identifier 'Ready'
const { Client, Intents } = require('discord.js'); const { REST } = require('@discordjs/rest'); const { Routes } = require('discord-api-types/v10'); const express = require('express'); // Initialize Discord bot const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] }); // Discord bot token and client ID const TOKEN = '1'; const CLIENT_ID = '1'; const GUILD_ID = '1'; const rest = new REST({ version: '10' }).setToken(TOKEN); const app = express(); app.use(express.json()); // Express logging middleware app.use((req, res, next) => { console.log([${new Date().toISOString()}] ${req.method} ${req.url}); next(); }); // Handle interactions from Discord slash commands app.post('/interactions', (req, res) => { console.log('Received interaction request:', req.body); const { type } = req.body; switch (type) { case 1: const response = { type: 1, data: { content: 'Hello, Slash Command!' } }; console.log('Sending response:', response); res.status(200).json(response); break; case 2: // Handle type 2 interaction // ... break; case 3: // Handle type 3 interaction // ... break; default: console.log('Unknown interaction type:', type); res.status(400).send('Unknown interaction type'); break; } }); // Start the Express server app.listen(3000, () => { console.log('Express server is running on port 3000'); }); // Bot event handling client.on('ready', () => { console.log([${new Date().toISOString()}] Bot logged in as ${client.user.tag}); registerSlashCommands().catch(error => { console.error('Failed to register slash commands:', error); }); }); client.on('error', error => { console.error('Discord client error:', error); }); // Function to register slash commands async function registerSlashCommands() { console.log('Attempting to register slash commands...'); const commands = [ { name: 'hello', description: 'A simple hello command' } ]; try { await rest.put(Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID), { body: commands, }); console.log('Successfully registered slash commands.'); } catch (error) { console.error('Error registering slash commands:', error); } } // Login the bot client.login(TOKEN) .then(() => console.log('Initiating bot login...')) .catch(error => console.error('Bot login failed:', error));
32 replies