Skip to content

Commit 8ae9069

Browse files
committed
Add safeReply function
1 parent ef4581f commit 8ae9069

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/lib/structures/contexts/CommandContext.ts

+4
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,8 @@ export class CommandContext<Cached extends CacheType = CacheType> extends Contex
6464
};
6565
this.type = 'COMMAND';
6666
}
67+
68+
public safeReply<Fetch extends boolean = boolean>(options?: InteractionReplyOptions & { fetchReply?: Fetch } | string | MessagePayload | InteractionReplyOptions): Promise<Fetch extends true ? GuildCacheMessage<Cached> : void> {
69+
return this.deferred || this.replied ? this.editReply(options) : this.reply(options);
70+
}
6771
}

src/lib/structures/contexts/ComponentContext.ts

+4
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,8 @@ export class ComponentContext<Cached extends CacheType = CacheType> extends Cont
7474
};
7575
this.type = options.type;
7676
}
77+
78+
public safeReply<Fetch extends boolean = boolean>(options?: InteractionReplyOptions & { fetchReply?: Fetch } | string | MessagePayload | InteractionReplyOptions): Promise<Fetch extends true ? GuildCacheMessage<Cached> : void> {
79+
return this.deferred || this.replied ? this.editReply(options) : this.reply(options);
80+
}
7781
}

0 commit comments

Comments
 (0)