Skip to content

Commit

Permalink
fix(bot): fixed unhelpful disallowed intents error message
Browse files Browse the repository at this point in the history
For some reason, discord.js stopped throwing unhandledRejection for those errors.... /shrug
  • Loading branch information
tabarra committed Apr 1, 2024
1 parent ca3ee54 commit 425b844
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 29 deletions.
11 changes: 10 additions & 1 deletion core/components/DiscordBot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,17 @@ export default class DiscordBot {
//Start bot
this.#client.login(this.config.token).catch((error) => {
clearInterval(disallowedIntentsWatcherId);

//for some reason, this is not throwing unhandled rejection anymore /shrug
if (error.message === 'Used disallowed intents') {
return sendError(
`This bot does not have a required privileged intent.`,
{ code: 'DisallowedIntents' }
);
}

//if no message, create one
if (!('message' in error) || !error.message){
if (!('message' in error) || !error.message) {
error.message = 'no reason available - ' + JSON.stringify(error);
}
console.error(`Discord login failed with error: ${error.message}`);
Expand Down
2 changes: 1 addition & 1 deletion core/webroutes/settings/save.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ async function handleDiscord(ctx: AuthedCtx) {
- Go to the Discord Dev Portal (https://discord.com/developers/applications)
- Navigate to \`Bot > Privileged Gateway Intents\`.
- Enable the \`GUILD_MEMBERS\` intent.
- Save on the dev portal.
- Press save on the developer portal.
- Go to the \`txAdmin > Settings > Discord Bot\` and press save.`;
} else if (errorCode === 'CustomNoGuild') {
const inviteUrl = ('clientId' in (error as any))
Expand Down
28 changes: 1 addition & 27 deletions docs/dev_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
- [x] fix(console): remove extra line break on term.write
- [x] Migrate `/database/` routes to `/history` (update panel, nui, web!)
- [x] Add StatisticsManager tracking for players/actions search duration (QuantileArray)
- [ ] fix disallowed intents message
- [x] fix disallowed intents message

> ????
- [ ] rtl issue
Expand All @@ -50,31 +50,6 @@ https://github.com/citizenfx/fivem/commit/84f724ed04d07e0b3a765601ad19ce54412f13
=======================================================================

### Action Modal:
Modal title: [BAN] BXXX-XXX
- info tab
- date
- author
- player (name or link?)
- STATUS
- WARN
- active: --
- revoked: revoked by XXX at YYY
- BAN
- active perma: permanent ban
- active temp: expires in XXX
- revoked: revoked by XXX at YYY
- expired: expired on XXX
- reason
- IDs tab (same from players)
- Edit tab
- for non-expired, non-revoked bans:
- same input as ban players modal
- button to "expire now"
- for non-viewed, non-revoked, offline warns
- change the reason

- Actions: revoke, remove (tbd)

- feat requests:
- be able to delete bans/warns with new permission (Issue #910)
- offline warning - show when rejoin and IS_PED_WALKING, requires showing when it happened to the player (Issue #522)
Expand All @@ -84,7 +59,6 @@ Modal title: [BAN] BXXX-XXX
- Thought: maybe we could use some dedicated icons for Expired, Edited, Revoked



#### Whitelist:
- remove the wl pending join table
- add a "latest whitelists" showing both pending and members (query players + pending and join tables)
Expand Down

0 comments on commit 425b844

Please sign in to comment.