-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js.backup
More file actions
39 lines (33 loc) · 1.12 KB
/
index.js.backup
File metadata and controls
39 lines (33 loc) · 1.12 KB
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
34
35
36
37
38
39
require('dotenv').config();
const { Client, GatewayIntentBits, Events } = require('discord.js');
// Initialize Discord client with environment variable
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
});
client.once(Events.ClientReady, (readyClient) => {
console.log(`✅ Bot is ready! Logged in as ${readyClient.user.tag}`);
});
// Handle all messages
client.on(Events.MessageCreate, (message) => {
if (message.author.bot) return; // Ignore messages from bots
if(message.content.startsWith('create')){
const url=message.content.split('create')[1];
return message.reply({
content: `Creating a new thread with URL: ${url}`,
})
}
message.reply('hello from server'); // Reply to every message
});
// Handle slash commands
client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isChatInputCommand()) return;
if (interaction.commandName === 'ping') {
await interaction.reply('Pong!');
}
});
// Login with token from environment variables
client.login(process.env.DISCORD_TOKEN);