Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```@bot.event
- async def on_message(message):
- if message.author.bot:
- return
- if "traded with" in message.content:
- mentioned_user = message.mentions[0] # Assuming only one user is mentioned
- channel = message.channel
- # Send a reaction to the initial trade message
- await message.add_reaction(":hourglass:") # Awaiting confirmation
- await confirmation_trade(mentioned_user, message.author, message)
- async def confirmation_trade(mentioned_user, initial_user, initial_message):
- def check(m):
- return m.author == mentioned_user and m.content.lower() in ['confirm', 'confirmed']
- try:
- response = await bot.wait_for('message', timeout=60.0, check=check)
- except nextcord.ext.TimeoutError:
- await initial_message.edit(content="Trade confirmation timed out. Trade not confirmed.")
- await initial_message.clear_reaction(":hourglass:")
- else:
- # Update user roles after confirmation
- guild = initial_message.guild
- roles = [role for role in guild.roles if role.name.isdigit()]
- roles.sort(key=lambda role: int(role.name))
- for user in [mentioned_user, initial_user]:
- user_roles = user.roles
- role_names = [str(role.name) for role in user_roles]
- user_role_integers = [int(name) for name in role_names if name.isdigit()]
- current_role = max(user_role_integers + [0])
- next_role_name = str(current_role + 1)
- if next_role_name not in role_names:
- for role in roles:
- if role.name == next_role_name:
- await user.add_roles(role)
- role_to_remove = nextcord.utils.get(roles, name=str(current_role))
- if role_to_remove:
- await user.remove_roles(role_to_remove)
- await initial_message.add_reaction(":white_check_mark:")
- await initial_message.clear_reaction(":hourglass:")```
Advertisement
Add Comment
Please, Sign In to add comment