feat: keep track of message responses for all commands

This commit is contained in:
Ryan 2025-01-05 19:24:19 -05:00
parent 3848deb887
commit 3c4480c834
Signed by: ErrorNoInternet
GPG Key ID: 2486BFB7B1E6A4A3
2 changed files with 20 additions and 11 deletions

View File

@ -96,11 +96,7 @@ async def on_message(message, edited=False):
elif len(output.strip()) == 0: elif len(output.strip()) == 0:
await utils.add_check_reaction(message) await utils.add_check_reaction(message)
else: else:
if message.id in executed_messages: await utils.channel_send(message, output)
await executed_messages[message.id].edit(output)
else:
response = await message.channel.send(output)
executed_messages[message.id] = response
case C.CLEAR | C.PURGE if message.author.id in constants.OWNERS: case C.CLEAR | C.PURGE if message.author.id in constants.OWNERS:
await commands.tools.clear(message) await commands.tools.clear(message)
case C.JOIN: case C.JOIN:

View File

@ -1,6 +1,7 @@
import disnake import disnake
import constants import constants
from state import message_responses
def format_duration(duration: int): def format_duration(duration: int):
@ -34,15 +35,27 @@ async def add_check_reaction(message):
async def reply(message, *args, **kwargs): async def reply(message, *args, **kwargs):
await message.reply( if message.id in message_responses:
*args, **kwargs, allowed_mentions=disnake.AllowedMentions.none() await message_responses[message.id].edit(
) *args, **kwargs, allowed_mentions=disnake.AllowedMentions.none()
)
else:
response = await message.reply(
*args, **kwargs, allowed_mentions=disnake.AllowedMentions.none()
)
message_responses[message.id] = response
async def channel_send(message, *args, **kwargs): async def channel_send(message, *args, **kwargs):
await message.channel.send( if message.id in message_responses:
*args, **kwargs, allowed_mentions=disnake.AllowedMentions.none() await message_responses[message.id].edit(
) *args, **kwargs, allowed_mentions=disnake.AllowedMentions.none()
)
else:
response = await message.channel.send(
*args, **kwargs, allowed_mentions=disnake.AllowedMentions.none()
)
message_responses[message.id] = response
async def invalid_user_handler(interaction): async def invalid_user_handler(interaction):