From c7eaa620a482309cd16c00eb901b7704fc1f68a7 Mon Sep 17 00:00:00 2001 From: Lemon Rose <78662983+japandotorg@users.noreply.github.com> Date: Sun, 11 Aug 2024 08:28:55 +0530 Subject: [PATCH] [NoDMs] fix type error in kwargs --- nodms/core.py | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/nodms/core.py b/nodms/core.py index bb49493..7dc6434 100644 --- a/nodms/core.py +++ b/nodms/core.py @@ -210,6 +210,7 @@ async def initialize(self) -> None: async def wait_until_cache_ready(self) -> None: await self._cache_ready.wait() + # TODO: shorten this async def _send_response( self, ctx: commands.Context, type: Literal["message", "command"] ) -> None: @@ -230,7 +231,25 @@ async def _send_response( }, ) if type.lower() == "command" and (command := ctx.command): - kwargs.update(command=CommandAdapter(command)) + kwargs: Dict[str, Any] = await process_tagscript( + ( + self.cache.message.message + if type.lower() == "message" + else self.cache.message.command + ), + { + "user": UserAdapter(ctx.author), + "author": UserAdapter(ctx.author), + "dm": DMChannelAdapter(ctx.channel), + "channel": DMChannelAdapter(ctx.channel), + "bot": BotAdapter(self.bot), + "{}".format(cast(discord.ClientUser, self.bot.user).name): BotAdapter( + self.bot + ), + "color": tse.StringAdapter(str(await ctx.embed_color())), + "command": CommandAdapter(command), + }, + ) if not kwargs: if type.lower() == "message": await cast(Group, self.config.message).message.clear() @@ -255,7 +274,21 @@ async def _send_response( }, ) if type.lower() == "command" and (command := ctx.command): - kwargs.update(command=CommandAdapter(command)) + kwargs = await process_tagscript( + message if type.lower() == "message" else command_message, + { + "user": UserAdapter(ctx.author), + "author": UserAdapter(ctx.author), + "dm": DMChannelAdapter(ctx.channel), + "channel": DMChannelAdapter(ctx.channel), + "bot": BotAdapter(self.bot), + "{}".format(cast(discord.ClientUser, self.bot.user).name): BotAdapter( + self.bot + ), + "color": tse.StringAdapter(str(await ctx.embed_color())), + "command": CommandAdapter(command), + }, + ) kwargs["reference"] = ctx.message.to_reference(fail_if_not_exists=False) kwargs["allowed_mentions"] = discord.AllowedMentions(replied_user=False) try: