This repository has been archived by the owner on Jan 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
bot.js
58 lines (57 loc) · 1.92 KB
/
bot.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
const { Client, MessageEmbed } = require("discord.js");
require("dotenv").config();
//const { Pagination } = require("djs-pagination-buttons");
const { Pagination } = require("../lib/index.js");
const client = new Client({
intents: ["GUILD_MESSAGES", "GUILDS"],
});
client.on("ready", () => {
console.log("Bot is online!");
});
client.on("error", console.error);
client.on("warn", console.warn);
client.on("messageCreate", async (message) => {
if (message.content !== "!deploy") return;
await client.application.commands.set([
{
name: "commands",
description: "Shows all commands!",
},
{
name: "ping",
description: "Shows my ping!",
},
{
name: "server",
description: "Show server's name",
},
]);
message.reply("Done!");
});
client.on("interactionCreate", async (interaction) => {
if (!interaction.isCommand()) return;
const { commandName: cmd } = interaction;
if (cmd === "commands") {
const pages = [
new MessageEmbed().setTitle("Page 1"),
new MessageEmbed().setTitle("Page 2"),
];
pages[0].setDescription(
"To see my commands, go to the next page using buttons."
);
pages[1].setDescription(
"My General commands\n```\n• commands - Shows all commands!\n• ping - Shows my ping!\n• server - Show server's name\n```"
);
const pagination = new Pagination(client);
pagination.setPages(pages);
pagination.setAuthorizedUsers([interaction.user.id]);
pagination.send(null, interaction);
} else if (cmd === "ping") {
await interaction.reply(`Pong!\nMy latency: ${client.ws.ping}ms`);
} else if (cmd === "server") {
await interaction.reply(
`This server's name is ${interaction.guild.name}`
);
}
});
client.login(process.env.DISCORD_TOKEN);