-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathts-index.ts
70 lines (62 loc) · 2.26 KB
/
ts-index.ts
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
import { Command, Core, MessageCore, MessagePages } from "discord.js-core";
import { ApplicationCommandOptionType, GatewayIntentBits } from "discord.js";
import "dotenv/config";
const core: Core = new Core(
{
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildMessageReactions],
allowedMentions: { repliedUser: false },
devMode: true,
prefix: "pt!",
token: process.env.TOKEN as string,
guildIds: ["736829048373903377"],
},
);
const pingCommand: Command = new Command({
name: "ping",
description: "Pong!",
supportsSlashCommand: true,
supportsContextMenu: true,
supportedContextMenus: ["MESSAGE", "USER"],
supportsMessageCommand: true,
run: async (ic) => {
const messageCores = [
new MessageCore({
message: { content: "Pong!" },
}),
new MessageCore({
message: { content: "Pong! 2" },
}),
];
const pages = new MessagePages({
messageCores: messageCores,
});
ic.reply(pages);
},
});
const mentionCommand = new Command({
name: "mention",
description: "Mentions a user",
messageCommandAliases: ["m"], // aliases for MessageCommand
args: {
"target": {
type: ApplicationCommandOptionType.User,
description: "The user to mention",
required: true,
},
},
supportsMessageCommand: false,
supportsContextMenu: true,
supportedContextMenus: ["USER"], // Types of context menus which this command supports
supportsSlashCommand: true,
run: async (ic, args) => {
// Type of ic is InteractionCore, which can combine Message and Interaction.
// You can reply to Message or Interaction in the same method with InteractionCore.
// If the interaction is from UserContextMenu, target id is in args["user"] (If from MessageContextMenu, in args["message"])
const target = ic.contextMenuUser ?? args?.["target"];
if (!target) return;
const mention = `<@${target.id}>`;
await ic.reply({ content: mention }); // Send reply message
},
});
core.addCommands(pingCommand, mentionCommand);
core.login(() => core.applyCommands());