From 4782d4c6a8ce9ebdb785f538788257d4d987cf15 Mon Sep 17 00:00:00 2001 From: flifloo Date: Sun, 2 Aug 2020 13:16:09 +0200 Subject: [PATCH] Change rorec edit command to edit message title and description --- extensions/rorec.py | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/extensions/rorec.py b/extensions/rorec.py index ea4c29e..4c29431 100644 --- a/extensions/rorec.py +++ b/extensions/rorec.py @@ -19,7 +19,6 @@ channel_id_re = re.compile(r"^<#([0-9]+)>$") class RoRec(commands.Cog): def __init__(self, bot: commands.Bot): self.bot = bot - self.edits = {} def description(self): return "Create role-reaction message to give role from a reaction add" @@ -54,8 +53,8 @@ class RoRec(commands.Cog): value="Create a new role-reaction message on the mentioned channel.\n" "You can specify a description and if you can pick only one role", inline=False) - embed.add_field(name="edit ", value="Edit a role-reaction message\n" - "You can also add a ... reaction on the message to edit", + embed.add_field(name="edit [description}", value="Edit a role-reaction message title and " + "description", inline=False) embed.add_field(name="set <message_id> <emoji> <@role1> [@role2] ...", value="Add/edit a emoji with linked roles", inline=False) @@ -89,23 +88,17 @@ class RoRec(commands.Cog): await ctx.message.add_reaction("\U0001f44d") @rorec.group("edit", pass_context=True) - async def rorec_edit(self, ctx: commands.Context, message_id: int): + async def rorec_edit(self, ctx: commands.Context, message_id: int, title: str, description: str = None): s = db.Session() - m = s.query(db.RoRec).filter(db.RoRec.message == message_id and db.RoRec.guild == ctx.guild.id).first() + m = self.get_message(s, message_id, ctx.guild.id) s.close() - if not m or message_id in self.edits: - raise BadArgument() - self.edits[message_id] = ctx - embed = Embed(title="Edit role-reaction message") - embed.add_field(name="", value="... Set emoji\n" - "... Remove emoji\n" - "... Switch only one role rule\n" - "... Delete message\n" - "... Exit") - message = await ctx.send(embed=embed) - for i in []: - await message.add_reaction(i) + message = await ctx.guild.get_channel(m.channel).fetch_message(m.message) + embed: Embed = message.embeds[0] + embed.title = title + embed.description = description + await message.edit(embed=embed) + await ctx.message.add_reaction("\U0001f44d") @rorec.group("set", pass_context=True) async def rorec_set(self, ctx: commands.Context, message_id: int, emoji: str):