The Situation:
I'm trying to make a simple discord bot with pycord, but every time I run the code it gives this error:
Traceback (most recent call last):
File "main.py", line 3, in <module>
bot = discord.Bot()
AttributeError: module 'discord' has no attribute 'Bot'
The code:
import discord
bot = discord.Bot()
@bot.slash_command()
async def test(ctx):
await ctx.send('Success!')
bot.run('token')
What I have Done:
I've already checked if I have pycord installed and if my token is correct.
PyCord 2 beta 1 has just been released, so you can now install it with
pip install py-cord==2.0.0b1
rather than installing the version from source.
In order to get the example to work though, you need to add the applications.commands
scope to your OAuth2 URL and re-register you bot with your test server.
Also, the quickstart guide now suggests adding a list of guild (server) id's when creating a slash_command
:
The
guild_ids
attribute contains a list of guilds where this command will be active. If you omit it, the command will be globally available, and may take up to an hour to register.