-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
76 lines (58 loc) · 2.42 KB
/
index.js
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
//https://konanbot.com
//https://konanbot.com/topmaroc
//https://konanbot.com/api/topmaroc
const axios = require('axios');
const { Client, GatewayIntentBits, EmbedBuilder } = require('discord.js');
const konanbot = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
});
konanbot.once('ready', () => {
console.log(`Logged in as ${konanbot.user.tag}!`);
});
konanbot.on('messageCreate', async (message) => {
if (message.author.bot) return;
const prefix = '!';
if (message.content.startsWith(prefix + 'topmaroc')) {
const apiUrl = 'https://konanbot.com/api/topmaroc';
try {
const response = await axios.get(apiUrl);
const { success, data } = response.data;
if (!success || !data.length) {
return message.channel.send({ content: `No leaderboard data is available at the moment.` });
}
const embed = new EmbedBuilder()
.setAuthor({ name: 'Top Servers Related Voice Members', iconURL: `${konanbot.user.displayAvatarURL({ dynamic: true })}`, url: 'https://discord.gg/dctTMk73Gp' })
.setTitle('Top 10 Server Voice Leaderboard')
.setFooter({ text: 'Powered by Konan Bot API', iconURL: 'https://cdn.discordapp.com/emojis/1248300099663167520.png' });
const fields = data.map((guild) => ({
name: `#${guild.top} - ${guild.tag}`,
value: `🎙 **Voice Count:** ${guild.score}`,
inline: false,
}));
embed.addFields(fields);
message.channel.send({ embeds: [embed] });
} catch (error) {
message.channel.send('Failed to fetch leaderboard data. Please try again later.');
}
}
});
konanbot.login('YOUR BOT TOKEN');
//https://konanbot.com
//https://konanbot.com/topmaroc
//https://konanbot.com/api/topmaroc
/**
* Copyright (c) 2024 [Master Dev Centre]
*
* This code is protected under copyright law. Unauthorized duplication,
* distribution, or modification of this code is strictly prohibited.
* Redistribution without proper authorization will result in penalties.
*
* By using this bot, you agree to these terms.
*/
//https://konanbot.com
//https://konanbot.com/topmaroc
//https://konanbot.com/api/topmaroc