refactory(say): now works in dms and priv channels

This commit is contained in:
neoarz
2025-10-17 23:35:29 -04:00
parent 025df159f7
commit c286c2a070

View File

@@ -47,12 +47,17 @@ class Say(commands.Cog, name="say"):
interaction = getattr(context, "interaction", None) interaction = getattr(context, "interaction", None)
if interaction is not None: if interaction is not None:
await interaction.response.defer(ephemeral=True) is_in_guild = context.guild is not None
await context.channel.send(message, allowed_mentions=allowed_mentions) await interaction.response.defer(ephemeral=is_in_guild)
try: try:
await interaction.delete_original_response() await context.channel.send(message, allowed_mentions=allowed_mentions)
except: if is_in_guild:
pass try:
await interaction.delete_original_response()
except:
pass
except discord.Forbidden:
await interaction.followup.send(message, allowed_mentions=allowed_mentions)
else: else:
try: try:
await context.message.delete() await context.message.delete()
@@ -94,12 +99,17 @@ class Say(commands.Cog, name="say"):
interaction = getattr(context, "interaction", None) interaction = getattr(context, "interaction", None)
if interaction is not None: if interaction is not None:
await interaction.response.defer(ephemeral=True) is_in_guild = context.guild is not None
await context.channel.send(embed=embed, allowed_mentions=allowed_mentions) await interaction.response.defer(ephemeral=is_in_guild)
try: try:
await interaction.delete_original_response() await context.channel.send(embed=embed, allowed_mentions=allowed_mentions)
except: if is_in_guild:
pass try:
await interaction.delete_original_response()
except:
pass
except discord.Forbidden:
await interaction.followup.send(embed=embed, allowed_mentions=allowed_mentions)
else: else:
try: try:
await context.message.delete() await context.message.delete()