From d7574b3baa779c4f5599d129b6c2c5a54e45dbd8 Mon Sep 17 00:00:00 2001 From: theimperious1 Date: Thu, 3 Oct 2024 08:57:14 -0400 Subject: [PATCH 1/2] Fix /say not working in in some text channels --- src/discord/commands/guild/d.say.ts | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/discord/commands/guild/d.say.ts b/src/discord/commands/guild/d.say.ts index f2c301f5c..84a6c8260 100644 --- a/src/discord/commands/guild/d.say.ts +++ b/src/discord/commands/guild/d.say.ts @@ -27,6 +27,10 @@ export const dSay: SlashCommand = { return false; } + if (!interaction.member) return false; + + const member: GuildMember = interaction.member as GuildMember; + const say = interaction.options.getString('say', true); let channel = interaction.options.getChannel('channel') @@ -38,8 +42,24 @@ export const dSay: SlashCommand = { return false; } + // Ensure only moderators can use /say in announcements + if ( + channel.type === ChannelType.GuildAnnouncement && + !member.roles.cache.has(env.ROLE_MODERATOR) + ) { + await interaction.editReply({ content: 'Only moderators can use this command in announcement channels!' }); + return false; + } + // Ensure that the channel used is a text channel - if (channel.type !== ChannelType.GuildText) { + if ( + channel.type !== ChannelType.GuildText && + channel.type !== ChannelType.GuildVoice && + channel.type !== ChannelType.PublicThread && + channel.type !== ChannelType.PrivateThread && + channel.type !== ChannelType.GuildAnnouncement && + channel.type !== ChannelType.GuildForum + ) { await interaction.editReply({ content: 'This command can only be used in a server!' }); return false; } @@ -57,8 +77,8 @@ export const dSay: SlashCommand = { const channelBotlog = await interaction.guild.channels.fetch(env.CHANNEL_BOTLOG) as TextChannel; if (channelBotlog) { - await channelBotlog.send(`${(interaction.member as GuildMember).displayName} made me say '${say}' \ -in ${channel.name}`); + await channelBotlog.send(`${member.displayName} made me say '${say}' \ + in ${channel.name}`); } return true; From 9827502759a2cbd6f22a11b9907fa6e200309c20 Mon Sep 17 00:00:00 2001 From: theimperious1 Date: Thu, 3 Oct 2024 09:03:40 -0400 Subject: [PATCH 2/2] lint is bad mkay how do i make this do it automatically mkay --- src/discord/commands/guild/d.say.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/discord/commands/guild/d.say.ts b/src/discord/commands/guild/d.say.ts index 84a6c8260..b6d6c5996 100644 --- a/src/discord/commands/guild/d.say.ts +++ b/src/discord/commands/guild/d.say.ts @@ -44,8 +44,8 @@ export const dSay: SlashCommand = { // Ensure only moderators can use /say in announcements if ( - channel.type === ChannelType.GuildAnnouncement && - !member.roles.cache.has(env.ROLE_MODERATOR) + channel.type === ChannelType.GuildAnnouncement + && !member.roles.cache.has(env.ROLE_MODERATOR) ) { await interaction.editReply({ content: 'Only moderators can use this command in announcement channels!' }); return false; @@ -53,12 +53,12 @@ export const dSay: SlashCommand = { // Ensure that the channel used is a text channel if ( - channel.type !== ChannelType.GuildText && - channel.type !== ChannelType.GuildVoice && - channel.type !== ChannelType.PublicThread && - channel.type !== ChannelType.PrivateThread && - channel.type !== ChannelType.GuildAnnouncement && - channel.type !== ChannelType.GuildForum + channel.type !== ChannelType.GuildText + && channel.type !== ChannelType.GuildVoice + && channel.type !== ChannelType.PublicThread + && channel.type !== ChannelType.PrivateThread + && channel.type !== ChannelType.GuildAnnouncement + && channel.type !== ChannelType.GuildForum ) { await interaction.editReply({ content: 'This command can only be used in a server!' }); return false;