Skip to content

Commit

Permalink
feat: ピン留めの際、チャンネルタイプチェックにスレッドを対象とするように
Browse files Browse the repository at this point in the history
  • Loading branch information
book000 committed Nov 6, 2023
1 parent be05170 commit e6b2423
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/events/pin-prefix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ export class PinPrefixEvent extends BaseDiscordEvent<'messageCreate'> {
if (!message.guild || !message.member) return
// Botは無視
if (message.author.bot) return
// サーバのテキストチャンネル以外は無視
if (message.channel.type !== ChannelType.GuildText) return
// サーバのテキストチャンネルとスレッド以外は無視
if (
message.channel.type !== ChannelType.GuildText &&
message.channel.type !== ChannelType.PublicThread &&
message.channel.type !== ChannelType.PrivateThread
)
return
// メッセージの先頭にピン絵文字がついていない場合は無視
if (!message.content.startsWith('📌')) return

Expand Down
9 changes: 7 additions & 2 deletions src/events/pin-reaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ export class PinReactionEvent extends BaseDiscordEvent<'messageReactionAdd'> {
if (!message.guild || !message.member) return
// Botは無視
if (user.bot) return
// サーバのテキストチャンネル以外は無視
if (message.channel.type !== ChannelType.GuildText) return
// サーバのテキストチャンネルとスレッド以外は無視
if (
message.channel.type !== ChannelType.GuildText &&
message.channel.type !== ChannelType.PublicThread &&
message.channel.type !== ChannelType.PrivateThread
)
return
// リアクションしたユーザにメッセージの書き込み権限がない場合は無視
const permissions = message.channel.permissionsFor(user)
if (!permissions || !permissions.has(PermissionFlagsBits.SendMessages))
Expand Down

0 comments on commit e6b2423

Please sign in to comment.