- An I.D.E. such as Visual Studio Code
- Python installed on your PC
- Visit the Discord Developer Portal
- Click
Create Application
- Under
Settings
select theBot
option - Select
Add Bot
and theYes, do it!
- Copy your
bot token
and paste it into a text file on your computer - Go to
OAuth2
, select thebot
scope, and select thePermissions
you would like the bot to have. - Copy and paste the url into a web browser to invite the bot
Please consult the documentation at https://discordpy.readthedocs.io/
- You can get the library directly from PyPI:
python3 -m pip install -U discord.py
- If you are using Windows, then the following should be used instead:
py -3 -m pip install -U discord.py
import discord
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$hello'):
await message.channel.send('Hello!')
token = open('token.txt', "r").read()
client.run(token)
main.py