-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
33 lines (27 loc) · 847 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { Client, GatewayIntentBits } from 'discord.js';
import dotenv from 'dotenv';
dotenv.config();
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
});
client.once('ready', () => {
console.log(`Logged in as ${client.user?.tag}`);
});
client.on('messageCreate', async (message) => {
if (message.author.bot) return;
try {
// For testing, just echo back the message
await message.channel.send(`You said: ${message.content}`);
} catch (error) {
console.error('Error processing message:', error);
await message.channel.send('Sorry, I encountered an error processing your message.');
}
});
client.login(process.env.DISCORD_TOKEN).catch((error) => {
console.error('Error logging in:', error);
process.exit(1);
});