Skip to content

Commit eb98000

Browse files
fix: use isinstance checks for bookmark permissions
1 parent 11b590c commit eb98000

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

monty/exts/utils/bookmark.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,10 @@ async def send_embed(
206206
@commands.command(name="bookmark", aliases=("bm", "pin"))
207207
async def bookmark(
208208
self,
209-
ctx: typing.Union[commands.Context, disnake.Interaction],
209+
ctx: typing.Union[commands.Context, disnake.ModalInteraction, disnake.ApplicationCommandInteraction],
210210
target_message: Optional[WrappedMessageConverter],
211211
*,
212212
title: str = "Bookmark",
213-
bypass_dm_check: bool = False,
214-
bypass_read_check: bool = False,
215213
) -> None:
216214
"""Send the author a link to `target_message` via DMs."""
217215
if not target_message:
@@ -224,11 +222,17 @@ async def bookmark(
224222
"\n3. Lookup by message URL"
225223
)
226224
target_message = ctx.message.reference.resolved
227-
if not target_message.guild and not bypass_dm_check:
225+
if not target_message.guild and not isinstance(
226+
ctx, (disnake.ModalInteraction, disnake.MessageCommandInteraction)
227+
):
228228
raise commands.NoPrivateMessage("You may only bookmark messages that aren't in DMs.")
229229

230230
result = await self.action_bookmark(
231-
ctx.channel, ctx.author, target_message, title, bypass_read_check=bypass_read_check
231+
ctx.channel,
232+
ctx.author,
233+
target_message,
234+
title,
235+
bypass_read_check=isinstance(ctx, (disnake.ModalInteraction, disnake.MessageCommandInteraction)),
232236
)
233237
if isinstance(result, disnake.Embed):
234238
if isinstance(ctx, disnake.Interaction):
@@ -294,8 +298,6 @@ async def message_bookmark(self, inter: disnake.MessageCommandInteraction) -> No
294298
modal_inter,
295299
inter.target,
296300
title=modal_inter.text_values["title"],
297-
bypass_dm_check=True,
298-
bypass_read_check=True,
299301
)
300302

301303
@commands.Cog.listener("on_button_click")

0 commit comments

Comments
 (0)