Skip to content

Commit a315cad

Browse files
committed
v14, top level error handlers, fixed djs and mdn docs
1 parent 84ad958 commit a315cad

File tree

13 files changed

+207
-311
lines changed

13 files changed

+207
-311
lines changed

package-lock.json

Lines changed: 9 additions & 110 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"name": "tph_docs_bot",
33
"version": "1.0.0",
4-
"description": "A Discord bot to display documentation ",
4+
"description": "A Discord bot to display documentation.",
55
"main": "dist/bot.js",
6+
"type": "module",
67
"scripts": {
78
"tsc": "tsc",
89
"start": "npm run tsc && npm run register-global-commands && node dist/bot.js",
@@ -15,11 +16,8 @@
1516
"author": "",
1617
"license": "ISC",
1718
"dependencies": {
18-
"@discordjs/builders": "^1.9.0",
19-
"@discordjs/rest": "^2.4.0",
20-
"discord-api-types": "^0.37.109",
2119
"discord.js": "^14.16.3",
22-
"discord.js-docs": "github:BenjammingKirby/discord.js-docs#typescriptRewrite",
20+
"discord.js-docs": "github:eirikhanasand/discord.js-docs",
2321
"dotenv": "^16.4.5",
2422
"fast-xml-parser": "^4.5.0",
2523
"flexsearch": "^0.7.43",

src/bot.ts

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
11
import "dotenv/config";
2-
import { Client, Collection, LimitedCollection } from "discord.js";
32
import { MyContext } from "./interfaces";
4-
import { loadCommands, interactionCreateHandler } from "./handlers/InteractionCreateHandler";
5-
import { messageHandler } from "./handlers/MessageHandler";
6-
import { deleteButtonHandler } from "./utils/CommandUtils";
3+
import { loadCommands, interactionCreateHandler } from "./handlers/InteractionCreateHandler.js";
4+
import { messageHandler } from "./handlers/MessageHandler.js";
5+
import { deleteButtonHandler } from "./utils/CommandUtils.js";
6+
import {
7+
ActivityType,
8+
Client,
9+
Collection,
10+
GatewayIntentBits,
11+
LimitedCollection,
12+
Partials
13+
} from "discord.js";
714

815
(async function () {
916
const context: MyContext = {
1017
client: new Client({
11-
intents: ["GUILDS", "GUILD_MESSAGES"],
18+
intents: [
19+
GatewayIntentBits.Guilds,
20+
GatewayIntentBits.GuildMessages
21+
],
1222
presence: {
13-
activities: [{ type: "PLAYING", name: "Read the docs" }],
23+
activities: [{ type: ActivityType.Playing, name: "Read the docs" }],
1424
status: "online",
1525
},
16-
// For DMs, a partial channel object is received, in order to receive dms, CHANNEL partials must be activated
17-
partials: ["CHANNEL"],
26+
// For DMs, a partial channel object is received, in order to
27+
// receive dms, Partials.Channel must be activated
28+
partials: [
29+
Partials.Channel
30+
],
1831
makeCache: (manager) => {
1932
//! Disabling these caches will break djs functionality
2033
const unsupportedCaches = [
@@ -30,7 +43,6 @@ import { deleteButtonHandler } from "./utils/CommandUtils";
3043
},
3144
}),
3245
commands: {
33-
autocompletes: new Collection(),
3446
buttons: new Collection(),
3547
selectMenus: new Collection(),
3648
slashCommands: new Collection(),
@@ -54,3 +66,15 @@ import { deleteButtonHandler } from "./utils/CommandUtils";
5466

5567
docsBot.login(process.env.TOKEN);
5668
})();
69+
70+
process.on("unhandledRejection", async (err) => {
71+
console.error("Top Level Unhandled Promise Rejection:\n", err)
72+
})
73+
74+
process.on("uncaughtException", async (err) => {
75+
console.error("Top Level Uncaught Promise Exception:\n", err)
76+
})
77+
78+
process.on("uncaughtExceptionMonitor", async (err) => {
79+
console.error("Top Level Uncaught Promise Exception (Monitor):\n", err)
80+
})

0 commit comments

Comments
 (0)