Facebook
From Eagle Stocx , 1 Month ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 147
  1. import requests
  2.  
  3. # Replace with your actual bot token, guild ID, and role ID
  4. BOT_TOKEN = 'YOUR_BOT_TOKEN'
  5. GUILD_ID = 'YOUR_GUILD_ID'
  6. ROLE_ID = 'YOUR_ROLE_ID'
  7.  
  8. # Discord API endpoint for modifying a role
  9. url = f'https://discord.com/api/v9/guilds/{GUILD_ID}/roles/{ROLE_ID}'
  10.  
  11. # Headers for authentication
  12. headers = {
  13.     'Authorization': f'Bot {BOT_TOKEN}',
  14.     'Content-Type': 'application/json'
  15. }
  16.  
  17. # Data for updating the role
  18. data = {
  19.     'name': 'New Role Name', # New name for the role
  20.     'permissions': 'permissions_integer_value', # Permissions integer (optional)
  21.     'color': 0x1ABC9C, # New color for the role (optional)
  22.     'hoist': True, # Whether the role should be displayed separately in the sidebar (optional)
  23.     'mentionable': True # Whether the role should be mentionable (optional)
  24. }
  25.  
  26. # Make the PATCH request to update the role
  27. response = requests.patch(url, headers=headers, json=data)
  28.  
  29. # Check if the request was successful
  30. if response.status_code == 200:
  31.     print('Role updated successfully.')
  32. else:
  33.     print(f'Failed to update role: {response.status_code}')
  34.     print(response.json())