Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- autoroles = {}
- @client.event
- async def on_ready():
- global autoroles
- with open("autorole.json", "r") as f:
- autoroles = json.load(f)
- @client.event
- async def on_member_join(member):
- global welcome_channel_dict
- global autoroles
- #welcome message
- await client.get_channel(channel_id).send(embed=embed)
- role = discord.utils.get(member.guild.roles, id=autoroles[str(member.guild.id)])
- await member.add_roles(role)
- @client.command()
- @commands.has_permissions(administrator=True)
- async def autorole(ctx, *, role : discord.Role=None):
- embed=discord.Embed(color=0x7289da, description=f"**Set autorole to** {role.mention}**?**")
- embed.set_footer(text="React with the wave reaction to confirm it!")
- msg = await ctx.send(embed=embed)
- def checkifnotbot(reaction, user):
- return user != client.user
- await msg.add_reaction('👋')
- reaction, user = await client.wait_for("reaction_add", timeout=60.0, check=checkifnotbot)
- if str(reaction.emoji) == "👋":
- embedw=discord.Embed(description=f"👋**Autorole set!**\n> Everytime someone joins the server they get the {role.mention} role!", color=0x7289da)
- await msg.edit(embed=embedw)
- await msg.clear_reactions()
- global autoroles
- autoroles[str(ctx.guild.id)] = role.id
- with open("autorole.json", "w") as f:
- json.dump(autoroles, f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement