-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
92 lines (75 loc) · 2.71 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
require('dotenv').config();
const { Client, GatewayIntentBits, REST } = require('discord.js');
const { Routes } = require('discord-api-types/v10');
const r34Command = require('./commands/Nsfw/r34Command');
const waifuSFWCommand = require('./commands/Anime/waifuSFWCommand');
const waifuNSFWCommand = require('./commands/Nsfw/waifuNSFWCommand');
const helpCommand = require('./commands/helpCommand');
const avatarCommand = require('./commands/Fun/avatar');
const avatarsCommand = require('./commands/util/avatar');
const nekobotCommand = require('./commands/Nsfw/nekobot');
const botinfoCommand = require('./commands/General/Info/botinfo');
const waifuCommannd = require('./commands/Fun/waifu');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
],
});
client.once('ready', () => {
console.log(`Logged in as ${client.user.tag}`);
});
const cooldowns = new Map();
client.on('interactionCreate', async (interaction) => {
if (interaction.isCommand()) {
const commandName = interaction.commandName;
const commands = {
r34: r34Command,
waifusfw: waifuSFWCommand,
waifunsfw: waifuNSFWCommand,
help: helpCommand,
profilepic: avatarCommand,
avatar: avatarsCommand,
nekobot: nekobotCommand,
botinfo: botinfoCommand,
waifu: waifuCommannd,
};
if (commands[commandName]) {
const cooldownTime = 3000; // 3 seconds cooldown
if (cooldowns.has(interaction.user.id)) {
const expirationTime = cooldowns.get(interaction.user.id) + cooldownTime;
if (Date.now() < expirationTime) {
return interaction.reply(`Please wait ${((expirationTime - Date.now()) / 1000).toFixed(1)} seconds before using the \`${commandName}\` command again.`);
}
}
cooldowns.set(interaction.user.id, Date.now());
await commands[commandName].execute(interaction);
}
}
});
client.login(process.env.DISCORD_TOKEN);
// Register the slash commands
const commands = [
r34Command.data,
waifuSFWCommand.data,
waifuNSFWCommand.data,
helpCommand.data,
avatarCommand.data,
avatarsCommand.data,
nekobotCommand.data,
botinfoCommand.data,
waifuCommannd.data,
];
const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_TOKEN);
(async () => {
try {
console.log('Started refreshing application (/) commands.');
await rest.put(
Routes.applicationGuildCommands(process.env.CLIENT_ID, process.env.GUILD_ID),
{ body: commands }
);
console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error); // Log the error here
}
})();