Skip to content

Commit

Permalink
Merge pull request #1125 from givepraise/fix/praise-in-pvt-threads
Browse files Browse the repository at this point in the history
fix(temp): block praise in pvt threads
  • Loading branch information
kristoferlund authored Aug 4, 2023
2 parents a3878aa + f9d42b5 commit cf2e2d1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/discord-bot/src/utils/assertPraiseAllowedInChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ export const assertPraiseAllowedInChannel = async (
getSetting('PRAISE_ALLOWED_CHANNEL_IDS', host) as Promise<string[]>,
]);

if (allowedInAllChannels) return true;

if (!channel) {
if (!channel || channel.type === ChannelType.PrivateThread) {
await interaction.editReply({
content:
'**❌ Missing Permissions**\nPraise bot can not work in private threads yet.',
});
return false;
}

if (allowedInAllChannels) return true;

if (!Array.isArray(allowedChannelsList) || allowedChannelsList.length === 0) {
await interaction.editReply({
content: '**❌ Praise Restricted**\nPraise not allowed in any channel.',
Expand All @@ -39,7 +40,10 @@ export const assertPraiseAllowedInChannel = async (
return false;
}

if (!allowedChannelsList.includes(getChannelId(channel))) {
if (
!allowedChannelsList.includes(getChannelId(channel)) &&
!allowedChannelsList.includes(channel.id)
) {
await interaction.editReply({
content: `**❌ Praise Restricted**\nPraise not allowed in this channel.\nTo praise, use the following channels - ${allowedChannelsList
.filter((el) => el !== '0')
Expand Down

0 comments on commit cf2e2d1

Please sign in to comment.