0
votes

I have a bot that I'm trying to make better. It's called moderator bot and I'm working on adding new commands. I just can't find the code anywhere.

How do I get moderator bot to give user roles when they join the server. And how do I make it configurable by the server owner so that the bot can be used over different servers?

I also want it to DM the owner commands so they can see it along with only owner-set roles being able to access that command.

It sounds advanced and probably is, but can someone out there write the code for me or tell me how to make that?

1
You have asked way too many questions in one question, plus, SO is not a place to request us to write code for you. We're here to help you when you have specific programming-related questions. See help center.abccd

1 Answers

5
votes

1) To make the bot give a member a role when they join, you need to have add_roles() in your on_member_join event. This can be accomplished with

@bot.event
async def on_member_join(member):
    role = discord.utils.get(member.server.roles, id="<role ID>")
    await bot.add_roles(member, role)

2) To have the role be customized for each server, you would need some file to hold the server id, and the role id to be given when the user joins (I personally would use a .db file, and sqlite3 to edit it from python, but you can do whatever you want). You would also need to slightly edit the on_member_join example I gave to select the role id based on the member.server.id from the file, and use the role id in discord.utils.get()

3) To have the bot DM anyone the default help messages, add pm_help=True to your Bot() parameters. To have part of your commands the average user and all sent to only the owner, you will need to make a new help command. To do this, you will need to add bot.remove_command('help') near the top of your code, and then create a command called help. Then, to have commands only sent to the owner, add

if ctx.message.author.id == ctx.message.server.owner.id:
    await bot.send_message(ctx.message.author, <help message>)

to your help command.

Hope this helps