-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.js
More file actions
76 lines (64 loc) · 2.31 KB
/
bot.js
File metadata and controls
76 lines (64 loc) · 2.31 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const Discord = require('discord.js');
const settings = require('./settings.json');
const client = new Discord.Client({
intents: [
Discord.GatewayIntentBits.Guilds,
Discord.GatewayIntentBits.GuildMessages,
Discord.GatewayIntentBits.MessageContent,
Discord.GatewayIntentBits.GuildMembers
]
});
let db;
module.exports.load = async function(app, database) {
db = database;
if (!settings.api.client.bot.token) {
console.warn("[BOT] Warning: Bot token not configured in settings.json");
return;
}
client.on('ready', () => {
console.log(`[BOT] Logged in as ${client.user.tag}`);
// Set bot status
client.user.setActivity('with Dashactyl', { type: Discord.ActivityType.Playing });
});
// Handle commands
client.on('messageCreate', async message => {
if (message.author.bot) return;
if (!message.guild) return;
const prefix = settings.api.client.bot.prefix || '!';
if (!message.content.startsWith(prefix)) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
// Example command: !stats
if (command === 'stats') {
const userCount = await db.get('users') || [];
message.reply({
embeds: [{
title: 'Dashboard Statistics',
description: `Total Users: ${userCount.length}`,
color: 0x3498db
}]
});
}
// Example command: !help
if (command === 'help') {
message.reply({
embeds: [{
title: 'Bot Commands',
description: `
${prefix}stats - Show dashboard statistics
${prefix}help - Show this help message
`,
color: 0x2ecc71
}]
});
}
});
// Login to Discord
try {
await client.login(settings.api.client.bot.token);
} catch (error) {
console.error('[BOT] Failed to login:', error.message);
}
};
// Export the client for use in other files
module.exports.client = client;