Search code examples
pythonoauth-2.0discorddiscord.py

Discord Authorize Application


I wanted to make a bot in Python which can automatically set up Servers for you. I know how to do everything with the bot except the part, where the Bot automatically adds you.

How can I authorize the application to allow it to add me to servers and how do I make it add me to a server afterwards?

Edit: I tried https://github.com/discord/discord-oauth2-example but that didn't work because of an invalid redirect URI.


Solution

  • I don't know about that, but I have a simple script that creates a guild, then creates an invite link and invites you to the guild that's been created.

    All you have to do afterwards is "!create Guild_Name"

    Here's the code;

    @bot.command()
    async def create(ctx, *, name):
        guild = await bot.create_guild(name=name)
        channel = await guild.create_text_channel('welcome')
        invite_link = await channel.create_invite()
        await ctx.send(f"Succesfully created **{guild.name}**. (ID: {guild.id})\n"
            f"{invite_link}")