feat: keep track of message responses for all commands
This commit is contained in:
parent
3848deb887
commit
3c4480c834
6
core.py
6
core.py
@ -96,11 +96,7 @@ async def on_message(message, edited=False):
|
||||
elif len(output.strip()) == 0:
|
||||
await utils.add_check_reaction(message)
|
||||
else:
|
||||
if message.id in executed_messages:
|
||||
await executed_messages[message.id].edit(output)
|
||||
else:
|
||||
response = await message.channel.send(output)
|
||||
executed_messages[message.id] = response
|
||||
await utils.channel_send(message, output)
|
||||
case C.CLEAR | C.PURGE if message.author.id in constants.OWNERS:
|
||||
await commands.tools.clear(message)
|
||||
case C.JOIN:
|
||||
|
25
utils.py
25
utils.py
@ -1,6 +1,7 @@
|
||||
import disnake
|
||||
|
||||
import constants
|
||||
from state import message_responses
|
||||
|
||||
|
||||
def format_duration(duration: int):
|
||||
@ -34,15 +35,27 @@ async def add_check_reaction(message):
|
||||
|
||||
|
||||
async def reply(message, *args, **kwargs):
|
||||
await message.reply(
|
||||
*args, **kwargs, allowed_mentions=disnake.AllowedMentions.none()
|
||||
)
|
||||
if message.id in message_responses:
|
||||
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):
|
||||
await message.channel.send(
|
||||
*args, **kwargs, allowed_mentions=disnake.AllowedMentions.none()
|
||||
)
|
||||
if message.id in message_responses:
|
||||
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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user