How to Make a Discord Server Through Bot Account

I’m trying to figure out how to make a new Discord server using my bot. I’ve been reading about the Guild Create event but I’m confused about when exactly a bot can create servers.

I thought maybe I should do it when the bot first starts up, so I put the server creation code in the on_ready function:

import discord
import asyncio

from mybot.config import get_token
from mybot.helpers import fetch_bot_owner

class MyDiscordBot(discord.Client):
    async def on_ready(self):
        new_server = await self.create_server("my_test_server")
        invitation = await self.create_invite(new_server.default_channel)
        await self.send_message(fetch_bot_owner())
        
my_bot = MyDiscordBot()
my_bot.run(get_token())

But when I run this I get an error saying 'NoneType' object has no attribute 'id'. It seems like the server creation failed somehow.

Can someone explain when bots are actually allowed to create servers? Is this even possible or am I missing something important? Any help would be great!

yeah this is a common mistake - that old create_server method doesnt work anymore and hasnt for years. discord killed it becuase of spam bots creating tons of servers. your code looks fine otherwise but that specific function just returns none now which is why you get the error. only way around it is making the server yourself first then adding the bot to it.

Discord actually removed server creation permissions for bots back in 2017. Regular bots can no longer create new servers through the API - this functionality was restricted due to abuse and spam issues. The create_server method you’re trying to use has been deprecated and will return None, which explains your NoneType error. What you can do instead is create the server manually through the Discord client, then invite your bot to it using OAuth2 with the appropriate permissions. Once your bot joins an existing server, it can manage channels, roles, and other server elements if it has the right permissions. Some verified bots with special partnerships might have server creation abilities, but this requires going through Discord’s official approval process which is quite restrictive.

You’re running into this issue because Discord deprecated the create_server() method several years ago for security reasons. The method still exists in some older documentation but it essentially does nothing now, which is why you’re getting None returned and subsequently the NoneType error when trying to access properties. I faced this same problem when I was working on a bot project last year. The workaround I ended up using was creating a template server manually first, then having the bot clone or modify existing servers that it’s already been invited to. You could also look into using Discord’s server templates feature where your bot can create servers from predefined templates, but this still requires the bot to have special permissions that most standard bots don’t get. For most use cases, you’ll need to create servers manually and then invite your bot with the necessary permissions to manage them. It’s definitely not as convenient as the old API allowed, but it’s the reality of how Discord handles bot permissions now.