def reason(self, ctx, num: CaseNumber, *, reason):
"""Sets the reason for a particular case.
You must own this case in order to edit the reason.
Negative numbers are allowed. They count starting from
the most recent case. e.g. -1 will show the newest case,
and -10 will show the 10th newest case.
"""
case = await self._get_case(ctx.session, ctx.guild.id, num)
if case is None:
return await ctx.send(f"Case #{num} doesn't exist.")
if case.mod_id != ctx.author.id:
return await ctx.send("This case is not yours.")
channel = ctx.guild.get_channel(case.channel_id)
if not channel:
return await ctx.send('This channel no longer exists... :frowning:')
message = await _get_message(channel, case.message_id)
if not message:
return await ctx.send('Somehow this message was deleted...')
embed = message.embeds[0]
reason_field = embed.fields[-1]
embed.set_field_at(-1, name=reason_field.name, value=reason, inline=False)
try:
await message.edit(embed=embed)
except discord.NotFound:
# In case the message was cached, and the message was deleted
# While it was still in the cache.
return await ctx.send('Somehow this message was deleted...')
case.reason = reason
await ctx.session.add(case)
await ctx.send('\N{OK HAND SIGN}')
评论列表
文章目录