Skip to content

Commit

Permalink
style. also take 2
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewj-brown committed Nov 8, 2023
1 parent 58262ad commit 4224ff4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions uqcsbot/yelling.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import discord
from typing import List, Dict, Callable, Any, Generic
from typing import List, Dict, Callable, Any
from discord.ext import commands
from discord._types import ClientT
from random import choice, random
Expand All @@ -12,9 +12,11 @@
from datetime import timedelta
from functools import wraps

class DodgyType(discord.interactions.Interaction[ClientT]):

class DodgyType(discord.interactions.InteractionResponse[ClientT]):
pass


def yelling_exemptor(input_args: List[str] = ["text"]) -> Callable[..., Any]:
def handler(func: Callable[..., Any]):
@wraps(func)
Expand All @@ -28,7 +30,7 @@ async def wrapper(
await func(cogself, *args, **kwargs)
return
for a in args:
if isinstance(a, DodgyType):
if isinstance(a, discord.interactions.Interaction):
interaction = a
break
if interaction is None:
Expand All @@ -49,7 +51,9 @@ async def wrapper(
if not Yelling.contains_lowercase(text):
await func(cogself, *args, **kwargs)
return
await interaction.response.send_message(

assert isinstance((x := interaction.response), DodgyType)
await x.send_message(
str(discord.utils.get(bot.emojis, name="disapproval") or "")
)
if isinstance(interaction.user, discord.Member):
Expand Down

0 comments on commit 4224ff4

Please sign in to comment.