discord-bot-shared 0.12.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +218 -102
- package/dist/bot.js +3 -3
- package/dist/command-manager.js +8 -8
- package/dist/event-manager.js +8 -3
- package/dist/types/command-manager.d.ts +2 -2
- package/dist/types/event-manager.d.ts +1 -1
- package/dist/types/util.d.ts +2 -2
- package/dist/util.js +5 -5
- package/package.json +6 -7
package/README.md
CHANGED
|
@@ -1,171 +1,287 @@
|
|
|
1
1
|
# discord-bot-shared
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A small package that makes creating [discord.js](https://github.com/discordjs/discord.js) bots a bit easier. It allows you easily create and register bot commands/events, handle runtime errors, and more.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Installation/Usage
|
|
5
|
+
---
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
- [Installation](#installation)
|
|
8
|
+
- [Quick Start](#quick-start)
|
|
9
|
+
- [Creating a `Bot` instance](#creating-a-bot-instance)
|
|
10
|
+
- [Commands](#commands)
|
|
11
|
+
- [Creating a slash command](#creating-a-slash-command)
|
|
12
|
+
- [Adding and registering commands](#adding-and-registering-commands)
|
|
13
|
+
- [Unregistering commands](#unregistering-commands)
|
|
14
|
+
- [Global Command Hook](#global-command-hook)
|
|
15
|
+
- [Events](#events)
|
|
16
|
+
- [Listening for event](#listening-for-event)
|
|
17
|
+
- [Adding and registering events](#adding-and-registering-events)
|
|
18
|
+
- [Error Handling](#error-handling)
|
|
19
|
+
- [Commands](#commands-1)
|
|
20
|
+
- [Events](#events-1)
|
|
21
|
+
- [Utilities](#utilities)
|
|
22
|
+
- [getChannel](#getchannel)
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
```sh
|
|
10
27
|
npm install discord-bot-shared
|
|
11
28
|
```
|
|
12
29
|
|
|
13
|
-
|
|
14
|
-
- By default, commands are registered globally. To register commands to a specific guild, you can optionally provide `GUILD_ID`.
|
|
30
|
+
## Quick Start
|
|
15
31
|
|
|
16
|
-
|
|
17
|
-
// index.ts
|
|
18
|
-
import login from 'discord-bot-shared'
|
|
19
|
-
import { ClientOptions, GatewayIntentBits as Intents, Partials } from 'discord.js'
|
|
32
|
+
Let's create a simple bot with one slash command.
|
|
20
33
|
|
|
21
|
-
|
|
22
|
-
intents: [Intents.Guilds],
|
|
23
|
-
partials: [Partials.Reaction],
|
|
24
|
-
}
|
|
34
|
+
In **`ping.ts`:**
|
|
25
35
|
|
|
26
|
-
|
|
36
|
+
```ts
|
|
37
|
+
import { Command } from "discord-bot-shared"
|
|
38
|
+
import { SlashCommandBuilder } from "discord.js"
|
|
27
39
|
|
|
28
|
-
|
|
40
|
+
const ping: Command = {
|
|
41
|
+
command: new SlashCommandBuilder().setName("ping").setDescription("I'll respond with pong!").toJSON(),
|
|
42
|
+
async run(interaction) {
|
|
43
|
+
await interaction.reply("Pong!")
|
|
44
|
+
},
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default ping
|
|
29
48
|
```
|
|
30
49
|
|
|
31
|
-
|
|
50
|
+
In **`index.ts`:**
|
|
32
51
|
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
52
|
+
```ts
|
|
53
|
+
import Bot from "discord-bot-shared"
|
|
54
|
+
import { ClientOptions, GatewayIntentBits } from "discord.js"
|
|
55
|
+
import ping from "./ping"
|
|
56
|
+
|
|
57
|
+
// Get applicationId and token from environment variables
|
|
58
|
+
const applicationId = process.env.APPLICATION_ID ?? ""
|
|
59
|
+
const token = process.env.BOT_TOKEN ?? ""
|
|
60
|
+
|
|
61
|
+
const clientOptions: ClientOptions = {
|
|
62
|
+
intents: [GatewayIntentBits.Guilds],
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const bot = new Bot({ applicationId, token, clientOptions })
|
|
66
|
+
|
|
67
|
+
bot.commands.add(ping)
|
|
68
|
+
|
|
69
|
+
await bot.commands.register()
|
|
70
|
+
await bot.login()
|
|
41
71
|
```
|
|
42
72
|
|
|
43
|
-
|
|
73
|
+
That's it! You now have bot that will respond to the slash command `/ping` with "Pong!".
|
|
44
74
|
|
|
45
|
-
|
|
75
|
+
## Creating a `Bot` instance
|
|
46
76
|
|
|
77
|
+
The `Bot` constructor takes an object that contains your bot's `applicationId`, secret `token`, and Discord `clientOptions`. See this [discord.js guide page](https://discordjs.guide/popular-topics/intents.html) for more info on setting up bot intents.
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
const bot = new Bot({ applicationId, token, clientOptions })
|
|
47
81
|
```
|
|
48
|
-
// guildMemberAdd.ts
|
|
49
|
-
import bot from '../index.js'
|
|
50
82
|
|
|
51
|
-
bot
|
|
52
|
-
|
|
53
|
-
|
|
83
|
+
Once you have your bot setup and are ready for it to start listening for the commands and events you've added:
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
await bot.login()
|
|
54
87
|
```
|
|
55
88
|
|
|
56
|
-
|
|
89
|
+
## Commands
|
|
57
90
|
|
|
58
|
-
|
|
91
|
+
### Creating a slash command
|
|
59
92
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
import {
|
|
93
|
+
Commands can be created by constructing `Command` objects that will be added to the bot later.
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
import { Command } from "discord-bot-shared"
|
|
97
|
+
import { SlashCommandBuilder } from "discord.js"
|
|
64
98
|
|
|
65
|
-
const
|
|
66
|
-
command: new SlashCommandBuilder()
|
|
67
|
-
|
|
68
|
-
.
|
|
69
|
-
run: (interaction) => {
|
|
70
|
-
// do stuff
|
|
99
|
+
const ping: Command = {
|
|
100
|
+
command: new SlashCommandBuilder().setName("ping").setDescription("I'll respond with pong!").toJSON(),
|
|
101
|
+
async run(interaction) {
|
|
102
|
+
await interaction.reply("Pong!")
|
|
71
103
|
},
|
|
72
104
|
}
|
|
73
105
|
|
|
74
|
-
export default
|
|
106
|
+
export default ping
|
|
75
107
|
```
|
|
76
108
|
|
|
77
|
-
|
|
109
|
+
Make sure to call `.toJSON()` on `SlashCommandBuilder`.
|
|
78
110
|
|
|
79
|
-
|
|
111
|
+
You can optionally provide a `requiredRoles` string array. If the member initiating the command has _any_ of the roles provided in this array, they will be allowed to run the command.
|
|
80
112
|
|
|
81
|
-
|
|
113
|
+
```ts
|
|
114
|
+
const ping: Command = {
|
|
115
|
+
requiredRoles: ["cool guy", "cooler guy"], // Only members that have a role with the name "cool guy" OR "cooler guy" can run this command.
|
|
116
|
+
command: // ...
|
|
117
|
+
run: // ...
|
|
118
|
+
}
|
|
119
|
+
```
|
|
82
120
|
|
|
83
|
-
|
|
121
|
+
### Adding and registering commands
|
|
84
122
|
|
|
85
|
-
|
|
123
|
+
You can add commands to the bot like so:
|
|
86
124
|
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
botIntents: ClientOptions,
|
|
90
|
-
projectMetaURL: string,
|
|
91
|
-
interactionCheck?: InteractionCheck,
|
|
92
|
-
): Promise<Client>
|
|
125
|
+
```ts
|
|
126
|
+
bot.commands.add(ping)
|
|
93
127
|
```
|
|
94
128
|
|
|
95
|
-
|
|
96
|
-
- `projectMetaURL` should always be passed `import.meta.url`. This is used to find and register your events and commands.
|
|
97
|
-
- Optionally provide an `interactionCheck` function that returns a boolean. This function is called right before trying to run a command. The command will only run if `interactionCheck` returns true.
|
|
98
|
-
- The `InteractionCheck` type is also exported by this module.
|
|
129
|
+
Commands must be registered before they will appear in Discord.
|
|
99
130
|
|
|
100
|
-
|
|
131
|
+
```ts
|
|
132
|
+
await bot.commands.register()
|
|
133
|
+
```
|
|
101
134
|
|
|
102
|
-
|
|
135
|
+
This registers commands globally (for all servers). It's not really recommended to register commands every time your bot starts up as you may get rate-limited by Discord.
|
|
103
136
|
|
|
104
|
-
|
|
137
|
+
### Unregistering commands
|
|
105
138
|
|
|
139
|
+
```ts
|
|
140
|
+
await bot.commands.unregisterApplicationCommands()
|
|
106
141
|
```
|
|
107
|
-
|
|
142
|
+
|
|
143
|
+
This will unregister all commands globally.
|
|
144
|
+
|
|
145
|
+
### Global Command Hook
|
|
146
|
+
|
|
147
|
+
You can optionally add a global command hook to your bot. This is a function that will be called before your command's `run` function.
|
|
148
|
+
|
|
149
|
+
- The global command hook function must return a `boolean`.
|
|
150
|
+
- If `true` is returned, the initiated command will run.
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
bot.commands.setGlobalCommandHook(commandHook)
|
|
108
154
|
```
|
|
109
155
|
|
|
110
|
-
|
|
156
|
+
This allows you to perform certain actions or make checks before _any_ command runs. For example, you could do something like this:
|
|
111
157
|
|
|
158
|
+
```ts
|
|
159
|
+
function commandHook(interaction: ChatInputCommandInteraction<"cached">) {
|
|
160
|
+
if (interaction.channelId === "123456789") {
|
|
161
|
+
return true
|
|
162
|
+
} else {
|
|
163
|
+
throwUserError("This command was not initiated in the right channel.")
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
bot.commands.setGlobalCommandHook(commandHook)
|
|
112
168
|
```
|
|
113
|
-
|
|
114
|
-
|
|
169
|
+
|
|
170
|
+
It's intended that you throw an error in the case you don't want the command to run rather than returning `false`. Otherwise, a generic error message will be displayed: `The global command hook returned false.`
|
|
171
|
+
|
|
172
|
+
`throwUserError` is a special helper function. See [Error Handling](#error-handling) for more info.
|
|
173
|
+
|
|
174
|
+
## Events
|
|
175
|
+
|
|
176
|
+
### Listening for event
|
|
177
|
+
|
|
178
|
+
You can create an `Event` object that will be added to the bot later.
|
|
179
|
+
|
|
180
|
+
```ts
|
|
181
|
+
import { Event } from "discord-bot-shared"
|
|
182
|
+
import { Events } from "discord.js"
|
|
183
|
+
|
|
184
|
+
const logNewMember: Event = {
|
|
185
|
+
event: Events.GuildMemberAdd,
|
|
186
|
+
handler(client, member) {
|
|
187
|
+
console.log(`${member.user.username} joined the server.`)
|
|
188
|
+
},
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export default logNewMember
|
|
115
192
|
```
|
|
116
193
|
|
|
117
|
-
|
|
194
|
+
The `Client` instance is always passed as the first argument to the `handler`. The rest of the arguments will be correctly typed based on the event you specify. Also, the `handler` can be `async` if needed.
|
|
118
195
|
|
|
119
|
-
|
|
196
|
+
### Adding and registering events
|
|
120
197
|
|
|
121
|
-
|
|
198
|
+
You can add events to the bot like so:
|
|
122
199
|
|
|
200
|
+
```ts
|
|
201
|
+
bot.events.add(logNewMember)
|
|
123
202
|
```
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
203
|
+
|
|
204
|
+
Unlike commands, events do not need to be registered separately. They will be listened for once the bot is logged in.
|
|
205
|
+
|
|
206
|
+
## Error Handling
|
|
207
|
+
|
|
208
|
+
This package makes it much easier to handle errors that are thrown during a command or event.
|
|
209
|
+
|
|
210
|
+
There are two helper functions you can import for throwing errors: `throwError` and `throwUserError`. (These also conveniently allow you to throw an error as an expression.)
|
|
211
|
+
|
|
212
|
+
- `throwError(message: string)`: Throw a `new Error` with `message`.
|
|
213
|
+
- `throwUserError(message: string)`: Throw a `new UserError` with `message`.
|
|
214
|
+
|
|
215
|
+
The usage of these is explained below.
|
|
216
|
+
|
|
217
|
+
### Commands
|
|
218
|
+
|
|
219
|
+
**TLDR:** Use `throwError` to display an error **with the stack trace** in the interaction reply. Use `throwUserError` to display the error message **only** in the interaction reply. That means by default, any instance of `Error` thrown (say by some function you don't own), will be displayed in the interaction reply with its stack trace (which is probably what you want).
|
|
220
|
+
|
|
221
|
+
When an error is thrown during a command, the interaction is replied to with the error message. For example:
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
import { Command, throwError } from "discord-bot-shared"
|
|
225
|
+
import { SlashCommandBuilder } from "discord.js"
|
|
226
|
+
|
|
227
|
+
const ping: Command = {
|
|
228
|
+
command: new SlashCommandBuilder().setName("ping").setDescription("I'll respond with pong!").toJSON(),
|
|
229
|
+
async run(interaction) {
|
|
230
|
+
if (interaction.member.id === "12345") {
|
|
231
|
+
await interaction.reply("Pong!")
|
|
232
|
+
} else {
|
|
233
|
+
throwError("Expected member with ID: 12345")
|
|
234
|
+
}
|
|
235
|
+
},
|
|
128
236
|
}
|
|
129
237
|
```
|
|
130
238
|
|
|
131
|
-
|
|
132
|
-
- **You may have to type cast your command `as SlashCommandBuilder` due to the way discord.js' `SlashCommandBuilder` works.**
|
|
133
|
-
- `run` is the final function that will be called to run your command.
|
|
239
|
+
If a member with an ID of `12345` does not initiate this command, the bot will respond with `There was an error while running this command.` along with the error **and stack trace**.
|
|
134
240
|
|
|
135
|
-
|
|
241
|
+
In most cases, you probably want to display a clean (i.e. without the stack trace) error message. That's where `throwUserError` comes in. If this type of error is thrown, only the provided error message is displayed.
|
|
136
242
|
|
|
137
|
-
|
|
243
|
+
As a more complete example, let's say we have some command that allows a member to level up when they have enough XP:
|
|
138
244
|
|
|
139
|
-
|
|
245
|
+
```ts
|
|
246
|
+
import { Command, throwUserError } from "discord-bot-shared"
|
|
247
|
+
import { SlashCommandBuilder } from "discord.js"
|
|
140
248
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
249
|
+
const levelUp: Command = {
|
|
250
|
+
command: new SlashCommandBuilder().setName("level-up").setDescription("Level up if you have enough XP.").toJSON(),
|
|
251
|
+
async run(interaction) {
|
|
252
|
+
const memberXP = getMemberXP(interaction.member.id) // This might throw!
|
|
253
|
+
|
|
254
|
+
if (memberXP >= 100) {
|
|
255
|
+
levelUpMember(interaction.member.id)
|
|
256
|
+
await interaction.reply("Level up!")
|
|
257
|
+
} else {
|
|
258
|
+
throwUserError("You don't have enough XP to level up!")
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
}
|
|
146
262
|
```
|
|
147
263
|
|
|
148
|
-
- `
|
|
149
|
-
-
|
|
150
|
-
- It is intended that you pass in a type for `T` that matches `channelType`. The returned channel is cast as whatever type is passed in.
|
|
151
|
-
- For example:
|
|
264
|
+
- Say `getMemberXP` throws because the underlying database call fails. The member that initiated the command will get a response with the error message and stack trace (which they can then send to you so you can debug the error).
|
|
265
|
+
- If the member doesn't have enough XP, they will receive the message about not having enough XP (no stack trace).
|
|
152
266
|
|
|
153
|
-
|
|
154
|
-
const someTextChannel = await getChannel<TextChannel>('some-text-channel', ChannelType.GuildText)
|
|
155
|
-
```
|
|
267
|
+
**This means that you should generally _not_ try to catch/handle errors in your commands and let it be handled by the bot.**
|
|
156
268
|
|
|
157
|
-
|
|
269
|
+
### Events
|
|
158
270
|
|
|
159
|
-
|
|
271
|
+
For events, all errors are caught and logged with `console.error`.
|
|
160
272
|
|
|
161
|
-
|
|
273
|
+
## Utilities
|
|
162
274
|
|
|
163
|
-
|
|
164
|
-
function isTextChannel(channel: BaseChannel | APIPartialChannel): channel is TextChannel
|
|
165
|
-
```
|
|
275
|
+
### getChannel
|
|
166
276
|
|
|
167
|
-
|
|
168
|
-
|
|
277
|
+
Returns the guild channel of the given name/ID and type, otherwise throws.
|
|
278
|
+
|
|
279
|
+
```ts
|
|
280
|
+
import { getChannel } from "discord-bot-shared"
|
|
281
|
+
import { ChannelType } from "discord.js"
|
|
282
|
+
|
|
283
|
+
// guild is of type Guild from discord.js
|
|
284
|
+
const someTextChannel = await getChannel(guild, "some-text-channel", ChannelType.GuildText)
|
|
169
285
|
```
|
|
170
286
|
|
|
171
|
-
|
|
287
|
+
Getting a properly typed channel with discord.js can be a bit of a pain, so this is an alternative.
|
package/dist/bot.js
CHANGED
|
@@ -18,11 +18,11 @@ class Bot {
|
|
|
18
18
|
async login() {
|
|
19
19
|
this.#discord.client.once(Events.ClientReady, () => {
|
|
20
20
|
console.log("Client is ready.");
|
|
21
|
-
this.commands._listen();
|
|
22
|
-
this.events._listen();
|
|
23
21
|
});
|
|
22
|
+
this.commands._listen();
|
|
23
|
+
this.events._listen();
|
|
24
24
|
await this.#discord.client.login(this.#discord.token);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
export default Bot;
|
|
28
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYm90LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2JvdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsTUFBTSxFQUFpQixNQUFNLEVBQUUsSUFBSSxFQUFFLE1BQU0sWUFBWSxDQUFBO0FBQ2hFLE9BQU8sY0FBYyxNQUFNLHNCQUFzQixDQUFBO0FBQ2pELE9BQU8sWUFBWSxNQUFNLG9CQUFvQixDQUFBO0FBZTdDLE1BQU0sR0FBRztJQUNQLFFBQVEsQ0FBZ0I7SUFFZixRQUFRLENBQWdCO0lBQ3hCLE1BQU0sQ0FBYztJQUU3QixZQUFZLE9BQW1CO1FBQzdCLElBQUksQ0FBQyxRQUFRLEdBQUc7WUFDZCxhQUFhLEVBQUUsT0FBTyxDQUFDLGFBQWE7WUFDcEMsS0FBSyxFQUFFLE9BQU8sQ0FBQyxLQUFLO1lBQ3BCLE1BQU0sRUFBRSxJQUFJLE1BQU0sQ0FBQyxPQUFPLENBQUMsYUFBYSxDQUFDO1lBQ3pDLElBQUksRUFBRSxJQUFJLElBQUksRUFBRSxDQUFDLFFBQVEsQ0FBQyxPQUFPLENBQUMsS0FBSyxDQUFDO1NBQ3pDLENBQUE7UUFFRCxJQUFJLENBQUMsUUFBUSxHQUFHLElBQUksY0FBYyxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsQ0FBQTtRQUNqRCxJQUFJLENBQUMsTUFBTSxHQUFHLElBQUksWUFBWSxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsQ0FBQTtJQUMvQyxDQUFDO0lBRUQsS0FBSyxDQUFDLEtBQUs7UUFDVCxJQUFJLENBQUMsUUFBUSxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLFdBQVcsRUFBRSxHQUFHLEVBQUU7WUFDakQsT0FBTyxDQUFDLEdBQUcsQ0FBQyxrQkFBa0IsQ0FBQyxDQUFBO1FBQ2pDLENBQUMsQ0FBQyxDQUFBO1FBRUYsSUFBSSxDQUFDLFFBQVEsQ0FBQyxPQUFPLEVBQUUsQ0FBQTtRQUN2QixJQUFJLENBQUMsTUFBTSxDQUFDLE9BQU8sRUFBRSxDQUFBO1FBQ3JCLE1BQU0sSUFBSSxDQUFDLFFBQVEsQ0FBQyxNQUFNLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsS0FBSyxDQUFDLENBQUE7SUFDdkQsQ0FBQztDQUNGO0FBRUQsZUFBZSxHQUFHLENBQUEifQ==
|
package/dist/command-manager.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Collection, Events, Routes, } from "discord.js";
|
|
2
|
-
import { UserError } from "./util.js";
|
|
2
|
+
import { UserError, throwUserError } from "./util.js";
|
|
3
3
|
class CommandManager {
|
|
4
4
|
#commands = new Collection();
|
|
5
|
-
#
|
|
5
|
+
#globalCommandHook;
|
|
6
6
|
#discord;
|
|
7
7
|
constructor(discord) {
|
|
8
8
|
this.#discord = discord;
|
|
@@ -13,8 +13,8 @@ class CommandManager {
|
|
|
13
13
|
add(command) {
|
|
14
14
|
this.#commands.set(command.command.name, command);
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
this.#
|
|
16
|
+
setGlobalCommandHook(commandHook) {
|
|
17
|
+
this.#globalCommandHook = commandHook;
|
|
18
18
|
}
|
|
19
19
|
async register() {
|
|
20
20
|
const payload = this.#commands.map((c) => c.command);
|
|
@@ -74,9 +74,9 @@ class CommandManager {
|
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
76
|
try {
|
|
77
|
-
const shouldContinue = this.#
|
|
77
|
+
const shouldContinue = this.#globalCommandHook ? await this.#globalCommandHook(interaction) : true;
|
|
78
78
|
if (!shouldContinue)
|
|
79
|
-
|
|
79
|
+
throwUserError("The global command hook returned false.");
|
|
80
80
|
await command.run(interaction);
|
|
81
81
|
}
|
|
82
82
|
catch (error) {
|
|
@@ -91,7 +91,7 @@ class CommandManager {
|
|
|
91
91
|
if (command.requiredRoles.length > 0) {
|
|
92
92
|
const member = await interaction.guild.members.fetch(interaction.user).catch(console.error);
|
|
93
93
|
if (!member)
|
|
94
|
-
return;
|
|
94
|
+
return false;
|
|
95
95
|
return member.roles.cache.some((role) => command.requiredRoles ? command.requiredRoles.includes(role.name) : false);
|
|
96
96
|
}
|
|
97
97
|
return false;
|
|
@@ -111,4 +111,4 @@ class CommandManager {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
export default CommandManager;
|
|
114
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
114
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbWFuZC1tYW5hZ2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2NvbW1hbmQtbWFuYWdlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBRUwsVUFBVSxFQUNWLE1BQU0sRUFFTixNQUFNLEdBQ1AsTUFBTSxZQUFZLENBQUE7QUFFbkIsT0FBTyxFQUFFLFNBQVMsRUFBRSxjQUFjLEVBQUUsTUFBTSxXQUFXLENBQUE7QUFVckQsTUFBTSxjQUFjO0lBQ2xCLFNBQVMsR0FBRyxJQUFJLFVBQVUsRUFBbUIsQ0FBQTtJQUM3QyxrQkFBa0IsQ0FBYztJQUNoQyxRQUFRLENBQWdCO0lBRXhCLFlBQVksT0FBdUI7UUFDakMsSUFBSSxDQUFDLFFBQVEsR0FBRyxPQUFPLENBQUE7SUFDekIsQ0FBQztJQUVEOztPQUVHO0lBQ0gsR0FBRyxDQUFDLE9BQW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SyxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUMsQ0FBQTtJQUN4RixDQUFDO0NBQ0Y7QUFFRCxlQUFlLGNBQWMsQ0FBQSJ9
|
package/dist/event-manager.js
CHANGED
|
@@ -12,12 +12,17 @@ class EventManager {
|
|
|
12
12
|
}
|
|
13
13
|
_listen() {
|
|
14
14
|
for (const event of this.#events) {
|
|
15
|
-
this.#discord.client.on(event.event, (...args) => {
|
|
16
|
-
|
|
15
|
+
this.#discord.client.on(event.event, async (...args) => {
|
|
16
|
+
try {
|
|
17
|
+
await event.handler(this.#discord.client, ...args);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
console.error(error);
|
|
21
|
+
}
|
|
17
22
|
});
|
|
18
23
|
}
|
|
19
24
|
console.log(`Listening for (${this.#events.length}) events.`);
|
|
20
25
|
}
|
|
21
26
|
}
|
|
22
27
|
export default EventManager;
|
|
23
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXZlbnQtbWFuYWdlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9ldmVudC1tYW5hZ2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQW1CQSxNQUFNLFlBQVk7SUFDaEIsT0FBTyxHQUFrQixFQUFFLENBQUE7SUFDM0IsUUFBUSxDQUFnQjtJQUV4QixZQUFZLE9BQXVCO1FBQ2pDLElBQUksQ0FBQyxRQUFRLEdBQUcsT0FBTyxDQUFBO0lBQ3pCLENBQUM7SUFFRDs7T0FFRztJQUNILEdBQUcsQ0FBd0IsS0FBcUI7UUFDOUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDLENBQUE7SUFDMUIsQ0FBQztJQUVELE9BQU87UUFDTCxLQUFLLE1BQU0sS0FBSyxJQUFJLElBQUksQ0FBQyxPQUFPLEVBQUU7WUFDaEMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLEtBQUssQ0FBQyxLQUFLLEVBQUUsS0FBSyxFQUFFLEdBQUcsSUFBSSxFQUFFLEVBQUU7Z0JBQ3JELElBQUk7b0JBQ0YsTUFBTyxLQUFLLENBQUMsT0FBd0IsQ0FBQyxJQUFJLENBQUMsUUFBUSxDQUFDLE1BQU0sRUFBRSxHQUFHLElBQUksQ0FBQyxDQUFBO2lCQUNyRTtnQkFBQyxPQUFPLEtBQUssRUFBRTtvQkFDZCxPQUFPLENBQUMsS0FBSyxDQUFDLEtBQUssQ0FBQyxDQUFBO2lCQUNyQjtZQUNILENBQUMsQ0FBQyxDQUFBO1NBQ0g7UUFDRCxPQUFPLENBQUMsR0FBRyxDQUFDLGtCQUFrQixJQUFJLENBQUMsT0FBTyxDQUFDLE1BQU0sV0FBVyxDQUFDLENBQUE7SUFDL0QsQ0FBQztDQUNGO0FBTUQsZUFBZSxZQUFZLENBQUEifQ==
|
|
@@ -5,12 +5,12 @@ interface Command {
|
|
|
5
5
|
command: RESTPostAPIChatInputApplicationCommandsJSONBody;
|
|
6
6
|
run: (interaction: ChatInputCommandInteraction<"cached">) => void | Promise<void>;
|
|
7
7
|
}
|
|
8
|
-
type CommandHook = (interaction: ChatInputCommandInteraction<"cached">) => Promise<boolean>;
|
|
8
|
+
type CommandHook = (interaction: ChatInputCommandInteraction<"cached">) => boolean | Promise<boolean>;
|
|
9
9
|
declare class CommandManager {
|
|
10
10
|
#private;
|
|
11
11
|
constructor(discord: DiscordContext);
|
|
12
12
|
add(command: Command): void;
|
|
13
|
-
|
|
13
|
+
setGlobalCommandHook(commandHook: CommandHook): void;
|
|
14
14
|
register(): Promise<void>;
|
|
15
15
|
unregisterGuildCommands(): Promise<void>;
|
|
16
16
|
private _unregisterGuildCommands;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Client, ClientEvents, Events } from "discord.js";
|
|
2
2
|
import { DiscordContext } from "./bot.js";
|
|
3
3
|
type ValidEvents = Exclude<Events, Events.VoiceServerUpdate | Events.Raw>;
|
|
4
|
-
type EventHandler<E extends ValidEvents = ValidEvents> = (client: Client
|
|
4
|
+
type EventHandler<E extends ValidEvents = ValidEvents> = (client: Client, ...args: ClientEvents[E]) => void | Promise<void>;
|
|
5
5
|
type EventHandlerMap = {
|
|
6
6
|
[E in ValidEvents]: EventHandler<E>;
|
|
7
7
|
};
|
package/dist/types/util.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ interface ChannelTypeToChannelMap {
|
|
|
8
8
|
[ChannelType.GuildForum]: ForumChannel;
|
|
9
9
|
}
|
|
10
10
|
declare function getChannel<T extends keyof ChannelTypeToChannelMap>(guild: Guild, channelNameOrId: string, channelType: T): Promise<ChannelTypeToChannelMap[T]>;
|
|
11
|
-
declare function throwError(
|
|
12
|
-
declare function throwUserError(
|
|
11
|
+
declare function throwError(message: string): never;
|
|
12
|
+
declare function throwUserError(message: string): never;
|
|
13
13
|
declare class UserError extends Error {
|
|
14
14
|
constructor(message: string);
|
|
15
15
|
}
|
package/dist/util.js
CHANGED
|
@@ -10,11 +10,11 @@ async function getChannel(guild, channelNameOrId, channelType) {
|
|
|
10
10
|
return channel;
|
|
11
11
|
throwError(`Failed to get channel: ${channelNameOrId}`);
|
|
12
12
|
}
|
|
13
|
-
function throwError(
|
|
14
|
-
throw new Error(
|
|
13
|
+
function throwError(message) {
|
|
14
|
+
throw new Error(message);
|
|
15
15
|
}
|
|
16
|
-
function throwUserError(
|
|
17
|
-
throw new UserError(
|
|
16
|
+
function throwUserError(message) {
|
|
17
|
+
throw new UserError(message);
|
|
18
18
|
}
|
|
19
19
|
class UserError extends Error {
|
|
20
20
|
constructor(message) {
|
|
@@ -24,4 +24,4 @@ class UserError extends Error {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
export { UserError, getChannel, throwError, throwUserError };
|
|
27
|
-
//# sourceMappingURL=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UMsT0FBZTtJQUNyQyxNQUFNLElBQUksU0FBUyxDQUFDLE9BQU8sQ0FBQyxDQUFBO0FBQzlCLENBQUM7QUFFRCxNQUFNLFNBQVUsU0FBUSxLQUFLO0lBQzNCLFlBQVksT0FBZTtRQUN6QixLQUFLLENBQUMsT0FBTyxDQUFDLENBQUE7UUFDZCxJQUFJLENBQUMsSUFBSSxHQUFHLElBQUksQ0FBQyxXQUFXLENBQUMsSUFBSSxDQUFBO1FBRWpDLE1BQU0sQ0FBQyxjQUFjLENBQUMsSUFBSSxFQUFFLEdBQUcsQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDLENBQUE7SUFDbkQsQ0FBQztDQUNGO0FBRUQsT0FBTyxFQUFFLFNBQVMsRUFBRSxVQUFVLEVBQUUsVUFBVSxFQUFFLGNBQWMsRUFBRSxDQUFBIn0=
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "discord-bot-shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Modules for creating discord bots.",
|
|
6
6
|
"repository": "github:adamhl8/discord-bot-shared",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"discord.js": "^14.0.0"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@types/node": "^20.6.
|
|
21
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
22
|
-
"@typescript-eslint/parser": "^6.
|
|
20
|
+
"@types/node": "^20.6.2",
|
|
21
|
+
"@typescript-eslint/eslint-plugin": "^6.7.0",
|
|
22
|
+
"@typescript-eslint/parser": "^6.7.0",
|
|
23
23
|
"discord.js": "^14.13.0",
|
|
24
24
|
"eslint": "^8.49.0",
|
|
25
25
|
"eslint-config-prettier": "^9.0.0",
|
|
@@ -32,10 +32,9 @@
|
|
|
32
32
|
"typescript": "^5.2.2"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
|
-
"build": "tsc",
|
|
35
|
+
"build": "rm -rf dist && tsc",
|
|
36
36
|
"format": "prettier --write .",
|
|
37
|
-
"lint": "eslint ./src/",
|
|
38
|
-
"prebuild": "pnpm format && pnpm lint && rm -rf dist",
|
|
37
|
+
"lint": "tsc --noEmit && eslint ./src/",
|
|
39
38
|
"prepublish": "pnpm build"
|
|
40
39
|
}
|
|
41
40
|
}
|