generated from nhcarrigan/template
feat: initial prototype
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @copyright NHCarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
|
||||
import {
|
||||
ChannelType,
|
||||
type Message,
|
||||
type OmitPartialGroupDMChannel,
|
||||
} from "discord.js";
|
||||
import { handleDmMessage } from "./handleDmMessage.js";
|
||||
import { handleThreadMessage } from "./handleThreadMessage.js";
|
||||
|
||||
/**
|
||||
* Handles the message event from Discord.
|
||||
* @param message -- The message payload from Discord.
|
||||
*/
|
||||
export const onMessage = async(
|
||||
message: OmitPartialGroupDMChannel<Message>,
|
||||
): Promise<void> => {
|
||||
if (message.channel.type === ChannelType.DM) {
|
||||
await handleDmMessage(message);
|
||||
return;
|
||||
}
|
||||
// This should not be true at this point, but we need to narrow this.
|
||||
if (!message.inGuild()) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
message.channel.type === ChannelType.PublicThread
|
||||
|| message.channel.type === ChannelType.PrivateThread
|
||||
) {
|
||||
await handleThreadMessage(message);
|
||||
return;
|
||||
}
|
||||
void message;
|
||||
};
|
||||
Reference in New Issue
Block a user