1
0
Fork 0

Change rorec edit command to edit message title and description

This commit is contained in:
Ethanell 2020-08-02 13:16:09 +02:00
parent b732349339
commit 4782d4c6a8

View file

@ -19,7 +19,6 @@ channel_id_re = re.compile(r"^<#([0-9]+)>$")
class RoRec(commands.Cog): class RoRec(commands.Cog):
def __init__(self, bot: commands.Bot): def __init__(self, bot: commands.Bot):
self.bot = bot self.bot = bot
self.edits = {}
def description(self): def description(self):
return "Create role-reaction message to give role from a reaction add" 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" 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", "You can specify a description and if you can pick only one role",
inline=False) inline=False)
embed.add_field(name="edit <message id>", value="Edit a role-reaction message\n" embed.add_field(name="edit <message id> <title> [description}", value="Edit a role-reaction message title and "
"You can also add a ... reaction on the message to edit", "description",
inline=False) inline=False)
embed.add_field(name="set <message_id> <emoji> <@role1> [@role2] ...", embed.add_field(name="set <message_id> <emoji> <@role1> [@role2] ...",
value="Add/edit a emoji with linked roles", inline=False) value="Add/edit a emoji with linked roles", inline=False)
@ -89,23 +88,17 @@ class RoRec(commands.Cog):
await ctx.message.add_reaction("\U0001f44d") await ctx.message.add_reaction("\U0001f44d")
@rorec.group("edit", pass_context=True) @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() 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() s.close()
if not m or message_id in self.edits:
raise BadArgument()
self.edits[message_id] = ctx message = await ctx.guild.get_channel(m.channel).fetch_message(m.message)
embed = Embed(title="Edit role-reaction message") embed: Embed = message.embeds[0]
embed.add_field(name="", value="... Set emoji\n" embed.title = title
"... Remove emoji\n" embed.description = description
"... Switch only one role rule\n" await message.edit(embed=embed)
"... Delete message\n" await ctx.message.add_reaction("\U0001f44d")
"... Exit")
message = await ctx.send(embed=embed)
for i in []:
await message.add_reaction(i)
@rorec.group("set", pass_context=True) @rorec.group("set", pass_context=True)
async def rorec_set(self, ctx: commands.Context, message_id: int, emoji: str): async def rorec_set(self, ctx: commands.Context, message_id: int, emoji: str):