From a8b0b42728d3c68f978e0d47730676b4edb1c04d Mon Sep 17 00:00:00 2001 From: AkatGabrielGoncalves Date: Thu, 2 Nov 2023 15:11:49 -0300 Subject: [PATCH] fix: crash when using commands in dm --- src/modules/CommandHandler.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/CommandHandler.ts b/src/modules/CommandHandler.ts index b118cd4..f677b9b 100644 --- a/src/modules/CommandHandler.ts +++ b/src/modules/CommandHandler.ts @@ -1,4 +1,4 @@ -import { CommandInteraction, Message, PermissionsBitField } from 'discord.js'; +import { ChannelType, CommandInteraction, Message, PermissionsBitField } from 'discord.js'; import { getChannelAuths } from '../database/queries/channelAuth'; import { getServer } from '../database/queries/server'; import Logger from '../logger/Logger'; @@ -49,7 +49,7 @@ export class CommandHandler extends CommandPermissionsHandler { }; public readonly message = async (message: Message) => { - if (message.author.bot) return null; + if (message.author.bot || message.channel.type === ChannelType.DM) return null; const guildId = message.guildId as string; @@ -67,7 +67,7 @@ export class CommandHandler extends CommandPermissionsHandler { }; public readonly interaction = async (interaction: CommandInteraction) => { - if (!interaction.isChatInputCommand()) return; + if (!interaction.isChatInputCommand() || !interaction.guild) return; const guildId = interaction.guildId as string;