From 64f53c38d7c7ee2206bf4db632abbcc1f2c7d8d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 8 Jun 2023 00:48:03 +0300 Subject: [PATCH] Remove ts-ignore and fix usage reason --- src/client/events/interactionCreate.ts | 17 +++++++++-------- src/client/funcs/check.ts | 6 +++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/client/events/interactionCreate.ts b/src/client/events/interactionCreate.ts index 0002943..8a5986d 100644 --- a/src/client/events/interactionCreate.ts +++ b/src/client/events/interactionCreate.ts @@ -1,17 +1,18 @@ -import { Interaction, PermissionFlagsBits } from "discord.js"; +import { ChannelType, Interaction, PermissionFlagsBits } from "discord.js"; import RadioClient from "../../Client"; export default function interactionCreate(client: RadioClient, interaction: Interaction) { if(!(interaction.isButton()) && !(interaction.isChatInputCommand()) && !(interaction.isStringSelectMenu())) return; - //@ts-ignore - const permissions = interaction.channel?.permissionsFor(interaction.client.user); - if (!permissions.has(PermissionFlagsBits.ViewChannel)) return; + if(interaction.channel?.type != ChannelType.DM){ + const permissions = interaction.channel?.permissionsFor(interaction.client.user); + if (!permissions?.has(PermissionFlagsBits.ViewChannel)) return; - if (!permissions.has(PermissionFlagsBits.EmbedLinks)) return interaction.reply({ - content: client.messages.emojis["error"] + client.messages.noPermsEmbed, - ephemeral: true - }); + if (!permissions?.has(PermissionFlagsBits.EmbedLinks)) return interaction.reply({ + content: client.messages.emojis["error"] + client.messages.noPermsEmbed, + ephemeral: true + }); + } if(interaction.isChatInputCommand()){ const commandName = interaction.commandName; diff --git a/src/client/funcs/check.ts b/src/client/funcs/check.ts index cafb5e5..63b6252 100644 --- a/src/client/funcs/check.ts +++ b/src/client/funcs/check.ts @@ -1,4 +1,4 @@ -import { ButtonInteraction, ChatInputCommandInteraction, StringSelectMenuInteraction } from "discord.js"; +import { ButtonInteraction, ChatInputCommandInteraction, GuildMember, StringSelectMenuInteraction } from "discord.js"; import RadioClient from "../../Client"; import { command } from "../commands"; @@ -21,8 +21,8 @@ export default function check(client: RadioClient, interaction: ButtonInteractio }); return false; } - //@ts-ignore - if (interaction.member.voice.channel !== radio.voiceChannel) { + + if (interaction.member instanceof GuildMember && interaction.member?.voice.channel !== radio.voiceChannel) { interaction.reply({ content: client.messages.emojis["error"] + client.messages.wrongVoiceChannel, ephemeral: true