Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix /say not working in in some text channels #849

Merged
merged 2 commits into from
Nov 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions src/discord/commands/guild/d.say.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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;
}
Expand All @@ -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;
Expand Down
Loading