You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Should the options of the SelectMenus be own objects or should they be created with create_option (then you would have to get the options and values from the dicts)?
If the 1st is the case, you could retrieve the values of the options from the select menu as an attribute, e.g. like this
@client.on_select()asyncdefchoice_roles(interaction):
awaitinteraction.defer()
roles= []
ifinteraction.component.values:
for_idininteraction.component.values:
roles.append(interaction.guild.get_role(int(_id)))
awaitinteraction.author.add_roles(*roles, reason='Self-Roles')
awaitinteraction.respond(f"Successfully added {', '.join([r.mention for r in roles])} tom you.", hidden=True)
else:
#yes, I know this looks complicated, but I'm going to add attributes to the discord.Message object that contain all the SelectMenus, buttons and generel componentsforoptionin [component.optionsforcomponentin [a.componentsforaininteraction.message.components] ifisinstance(component, SelectMenu)]:
role=interaction.guild.get_role(int(option.value))
ifroleininteraction.author.roles:
roles.append(role)
ifroles:
awaitinteraction.author.remove_roles(*roles, reason='Self-Roles')
awaitinteraction.respond(f"Successfully removed {', '.join([r.mention for r in roles])} from you.", hidden=True)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Should the options of the
SelectMenus
be own objects or should they be created withcreate_option
(then you would have to get the options and values from the dicts)?If the 1st is the case, you could retrieve the values of the options from the select menu as an attribute, e.g. like this
Beta Was this translation helpful? Give feedback.
All reactions