Merge branch 'rolegiver_patch' into 'main'
Fix rolegiver See merge request stark-industries/j.a.r.v.i.s.!39
This commit is contained in:
commit
2288ef3c10
1 changed files with 40 additions and 24 deletions
|
@ -230,42 +230,58 @@ class RolegiverCog(commands.Cog):
|
||||||
select = create_select(
|
select = create_select(
|
||||||
options=options,
|
options=options,
|
||||||
custom_id="to_delete",
|
custom_id="to_delete",
|
||||||
placeholder="Select roles to remove",
|
placeholder="Select roles to add",
|
||||||
min_values=1,
|
min_values=1,
|
||||||
max_values=len(options),
|
max_values=len(options),
|
||||||
)
|
)
|
||||||
components = [create_actionrow(select)]
|
components = [create_actionrow(select)]
|
||||||
|
|
||||||
_ = await ctx.send(content="\u200b", components=components)
|
message = await ctx.send(content="\u200b", components=components)
|
||||||
|
|
||||||
await ctx.author.add_roles(role, reason="Rolegiver")
|
try:
|
||||||
|
|
||||||
roles = ctx.author.roles
|
context = await wait_for_component(
|
||||||
if roles:
|
self.bot,
|
||||||
roles.sort(key=lambda x: -x.position)
|
check=lambda x: ctx.author.id == x.author.id,
|
||||||
_ = roles.pop(-1)
|
message=message,
|
||||||
|
timeout=60 * 5,
|
||||||
|
)
|
||||||
|
|
||||||
value = "\n".join([r.mention for r in roles]) if roles else "None"
|
role = ctx.guild.get_role(context.selected_options[0])
|
||||||
fields = [
|
|
||||||
Field(name="Added Role", value=f"{role.mention}"),
|
|
||||||
Field(name="Prior Role(s)", value=value),
|
|
||||||
]
|
|
||||||
|
|
||||||
embed = build_embed(
|
await ctx.author.add_roles(role, reason="Rolegiver")
|
||||||
title="User Given Role",
|
|
||||||
description=f"{role.mention} given to {ctx.author.mention}",
|
|
||||||
fields=fields,
|
|
||||||
)
|
|
||||||
|
|
||||||
embed.set_thumbnail(url=ctx.guild.icon_url)
|
roles = ctx.author.roles
|
||||||
embed.set_author(
|
if roles:
|
||||||
name=ctx.author.nick if ctx.author.nick else ctx.author.name,
|
roles.sort(key=lambda x: -x.position)
|
||||||
icon_url=ctx.author.avatar_url,
|
_ = roles.pop(-1)
|
||||||
)
|
|
||||||
|
|
||||||
embed.set_footer(text=f"{ctx.author.name}#{ctx.author.discriminator} | {ctx.author.id}")
|
value = "\n".join([r.mention for r in roles]) if roles else "None"
|
||||||
|
fields = [
|
||||||
|
Field(name="Added Role", value=f"{role.mention}"),
|
||||||
|
Field(name="Prior Role(s)", value=value),
|
||||||
|
]
|
||||||
|
|
||||||
await ctx.send(embed=embed)
|
embed = build_embed(
|
||||||
|
title="User Given Role",
|
||||||
|
description=f"{role.mention} given to {ctx.author.mention}",
|
||||||
|
fields=fields,
|
||||||
|
)
|
||||||
|
|
||||||
|
embed.set_thumbnail(url=ctx.guild.icon_url)
|
||||||
|
embed.set_author(
|
||||||
|
name=ctx.author.nick if ctx.author.nick else ctx.author.name,
|
||||||
|
icon_url=ctx.author.avatar_url,
|
||||||
|
)
|
||||||
|
|
||||||
|
embed.set_footer(text=f"{ctx.author.name}#{ctx.author.discriminator} | {ctx.author.id}")
|
||||||
|
|
||||||
|
await ctx.send(embed=embed)
|
||||||
|
except asyncio.TimeoutError:
|
||||||
|
for row in components:
|
||||||
|
for component in row["components"]:
|
||||||
|
component["disabled"] = True
|
||||||
|
await message.edit(components=components)
|
||||||
|
|
||||||
@cog_ext.cog_subcommand(
|
@cog_ext.cog_subcommand(
|
||||||
base="role",
|
base="role",
|
||||||
|
|
Loading…
Add table
Reference in a new issue