Advertisement
Rensjuh

Untitled

Mar 2nd, 2021
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.39 KB | None | 0 0
  1. autoroles = {}
  2.  
  3. @client.event
  4. async def on_ready():
  5.   global autoroles
  6.   with open("autorole.json", "r") as f:
  7.       autoroles = json.load(f)
  8.  
  9. @client.event
  10. async def on_member_join(member):
  11.     global welcome_channel_dict
  12.     global autoroles
  13.     #welcome message
  14.     await client.get_channel(channel_id).send(embed=embed)
  15.    
  16.     role = discord.utils.get(member.guild.roles, id=autoroles[str(member.guild.id)])
  17.  
  18.     await member.add_roles(role)
  19.  
  20. @client.command()
  21. @commands.has_permissions(administrator=True)
  22. async def autorole(ctx, *, role : discord.Role=None):
  23.  
  24.   embed=discord.Embed(color=0x7289da, description=f"**Set autorole to** {role.mention}**?**")
  25.   embed.set_footer(text="React with the wave reaction to confirm it!")
  26.   msg = await ctx.send(embed=embed)
  27.  
  28.   def checkifnotbot(reaction, user):
  29.       return user != client.user
  30.  
  31.   await msg.add_reaction('👋')
  32.  
  33.   reaction, user = await client.wait_for("reaction_add", timeout=60.0, check=checkifnotbot)
  34.  
  35.   if str(reaction.emoji) == "👋":  
  36.  
  37.     embedw=discord.Embed(description=f"👋**Autorole set!**\n> Everytime someone joins the server they get the {role.mention} role!", color=0x7289da)    
  38.     await msg.edit(embed=embedw)
  39.     await msg.clear_reactions()
  40.    
  41.     global autoroles
  42.     autoroles[str(ctx.guild.id)] = role.id
  43.  
  44.     with open("autorole.json", "w") as f:
  45.         json.dump(autoroles, f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement