fix (tasklist): Catch lack of permissions.

This commit is contained in:
2023-09-03 04:07:41 +03:00
parent 8d17dff632
commit 8d873a3505

View File

@@ -184,6 +184,25 @@ class TasklistCog(LionCog):
tasklist = await Tasklist.fetch(self.bot, self.data, userid) tasklist = await Tasklist.fetch(self.bot, self.data, userid)
if await self.is_tasklist_channel(channel): if await self.is_tasklist_channel(channel):
# Check we have permissions to send a regular message here
my_permissions = channel.permissions_for(guild.me)
if not my_permissions.embed_links or not my_permissions.send_messages:
t = self.bot.translator.t
error = discord.Embed(
colour=discord.Colour.brand_red(),
title=t(_p(
'summon_tasklist|error:insufficient_perms|title',
"Uh-Oh, I cannot do that here!"
)),
description=t(_p(
'summon_tasklist|error:insufficient_perms|desc',
"This channel is configured as a tasklist channel, "
"but I lack the `EMBED_LINKS` or `SEND_MESSAGES` permission here! "
"If you believe this is unintentional, please contact a server administrator."
))
)
await interaction.edit_original_response(embed=error)
else:
tasklistui = TasklistUI.fetch(tasklist, channel, guild, timeout=None) tasklistui = TasklistUI.fetch(tasklist, channel, guild, timeout=None)
await tasklistui.summon(force=True) await tasklistui.summon(force=True)
await interaction.delete_original_response() await interaction.delete_original_response()