File tree Expand file tree Collapse file tree 3 files changed +19
-4
lines changed
Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 11import { GuildTextBasedChannel , PermissionsBitField } from "discord.js" ;
22import { AutoReaction } from "../../../data/entities/AutoReaction.js" ;
3- import { isDiscordAPIError } from "../../../utils.js" ;
3+ import { isDiscordAPIError , isDiscordJsTypeError } from "../../../utils.js" ;
44import { getMissingChannelPermissions } from "../../../utils/getMissingChannelPermissions.js" ;
55import { missingPermissionError } from "../../../utils/missingPermissionError.js" ;
66import { readChannelPermissions } from "../../../utils/readChannelPermissions.js" ;
@@ -53,7 +53,12 @@ export const AddReactionsEvt = autoReactionsEvt({
5353 try {
5454 await message . react ( reaction ) ;
5555 } catch ( e ) {
56- if ( isDiscordAPIError ( e ) ) {
56+ if ( isDiscordJsTypeError ( e ) ) {
57+ const logs = pluginData . getPlugin ( LogsPlugin ) ;
58+ logs . logBotAlert ( {
59+ body : `Could not apply auto-reactions in <#${ channel . id } > for message \`${ message . id } \`: ${ e . message } .` ,
60+ } ) ;
61+ } else if ( isDiscordAPIError ( e ) ) {
5762 const logs = pluginData . getPlugin ( LogsPlugin ) ;
5863 if ( e . code === 10008 ) {
5964 logs . logBotAlert ( {
Original file line number Diff line number Diff line change 11import { Snowflake } from "discord.js" ;
22import { GuildPluginData } from "vety" ;
33import { ReactionRole } from "../../../data/entities/ReactionRole.js" ;
4- import { isDiscordAPIError , sleep } from "../../../utils.js" ;
4+ import { isDiscordAPIError , isDiscordJsTypeError , sleep } from "../../../utils.js" ;
55import { LogsPlugin } from "../../Logs/LogsPlugin.js" ;
66import { ReactionRolesPluginType } from "../types.js" ;
77
@@ -72,7 +72,12 @@ export async function applyReactionRoleReactionsToMessage(
7272 await targetMessage . react ( rawEmoji ) ;
7373 await sleep ( 750 ) ; // Make sure we don't hit rate limits
7474 } catch ( e ) {
75- if ( isDiscordAPIError ( e ) ) {
75+ if ( isDiscordJsTypeError ( e ) ) {
76+ errors . push ( e . message ) ;
77+ logs . logBotAlert ( {
78+ body : `Error ${ e . code } while applying reaction role reactions to ${ channelId } /${ messageId } : ${ e . message } .` ,
79+ } ) ;
80+ } else if ( isDiscordAPIError ( e ) ) {
7681 if ( e . code === 10014 ) {
7782 pluginData . state . reactionRoles . removeFromMessage ( messageId , rawEmoji ) ;
7883 errors . push ( `Unknown emoji: ${ rawEmoji } ` ) ;
Original file line number Diff line number Diff line change 33 ChannelType ,
44 Client ,
55 DiscordAPIError ,
6+ DiscordjsTypeError ,
67 EmbedData ,
78 EmbedType ,
89 Emoji ,
@@ -83,6 +84,10 @@ export function isDiscordAPIError(err: Error | string): err is DiscordAPIError {
8384 return err instanceof DiscordAPIError ;
8485}
8586
87+ export function isDiscordJsTypeError ( err : unknown ) : err is DiscordjsTypeError {
88+ return err instanceof DiscordjsTypeError ;
89+ }
90+
8691// null | undefined -> undefined
8792export function zNullishToUndefined < T extends z . ZodTypeAny > (
8893 type : T ,
You can’t perform that action at this time.
0 commit comments