mirror of
https://github.com/kirameki-cafe/Yumi.git
synced 2026-09-13 18:59:19 +00:00
Better message and interaction support
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { MessageEmbed, User, MessagePayload, MessageOptions, TextBasedChannels, TextChannel, DMChannel, BaseGuildTextChannel, Message, ColorResolvable } from "discord.js";
|
||||
import { MessageEmbed, User, MessagePayload, MessageOptions, TextBasedChannels, TextChannel, DMChannel, BaseGuildTextChannel, Message, ColorResolvable, Interaction, InteractionReplyOptions } from "discord.js";
|
||||
import App from "..";
|
||||
import Logger from "../libs/Logger";
|
||||
|
||||
@@ -85,6 +85,36 @@ export async function sendReply(rMessage: Message, options: string | MessagePayl
|
||||
|
||||
}
|
||||
|
||||
|
||||
export async function sendMessageOrInteractionResponse(data: Message | Interaction, payload: MessageOptions | InteractionReplyOptions) {
|
||||
const isSlashCommand = data instanceof Interaction && data.isCommand();
|
||||
const isMessage = data instanceof Message;
|
||||
|
||||
if(isSlashCommand) {
|
||||
if(!data.replied) {
|
||||
let message;
|
||||
try { return await data.reply(payload); }
|
||||
catch(errorDM) {
|
||||
Logger.error(`Cannot find available destinations to send the message CID: ${data.channel!.id} UID: ${data.user.id} DM_ERR: ${errorDM}`);
|
||||
return;
|
||||
} finally {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
else {
|
||||
let message;
|
||||
try { return await data.followUp(payload); }
|
||||
catch(errorDM) {
|
||||
Logger.error(`Cannot find available destinations to send the message CID: ${data.channel!.id} UID: ${data.user.id} DM_ERR: ${errorDM}`);
|
||||
return;
|
||||
} finally {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(isMessage) return await sendReply(data, payload);
|
||||
}
|
||||
|
||||
export function getEmotes() {
|
||||
return emotes;
|
||||
}
|
||||
Reference in New Issue
Block a user