How to join a server?

前端 未结 3 1405
不思量自难忘°
不思量自难忘° 2020-12-12 16:44

I\'m trying to setup a discord bot with python. I have a pre-existing discord server that I would like the bot to join, but I\'m having a hard time doing so.



        
相关标签:
3条回答
  • 2020-12-12 17:09

    It's been 4 years since I asked the question and here's how I deal with this problem nowadays.

    I use https://discordapi.com/permissions.html where you just paste your bot's ID (which you can get here: https://discord.com/developers/applications ) and it also has the benefit of calculating whatever permissions configuration you want for you.

    If you're lazy, this could be a decent solution for you too.

    0 讨论(0)
  • 2020-12-12 17:23

    I suggest editing the code like this:

        @client.event
    async def on_ready():
        print('Logged in as')
        print(client.user.name)
        print(client.user.id)
        print('Invite: https://discordapp.com/oauth2/authorize?client_id={}&scope=bot'.format(client.user.id))
        print('------')
    

    I think this is the best and easiest solution. It works for me.

    EDIT: Discord actually made their own OAuth2 url generator, so use that: https://discordapp.com/developers/tools/oauth2-url-generator

    0 讨论(0)
  • 2020-12-12 17:27

    I had some trouble with this as well. What you need to do is:

    1. Go to the Discord developer pages (login if you haven't).
    2. Go to the application with the bot you want to add to your channel.
    3. Copy the Client/Application ID.
    4. Go to https://discordapp.com/oauth2/authorize?client_id=CLIENT_ID_GOES_HERE&scope=bot&permissions=0 < You can set permissions for the bot here. Permissions can be calculated here.
    5. Select server and click authorize.

    Your bot will now be a member of the server and will respond to commands you give it. Ex. !test in the code you have given.

    EDIT: You can now use the permissions link (1) to generate the entire URL needed.

    0 讨论(0)
提交回复
热议问题