Create a Discord API account then run python bot.py
.
Created
March 31, 2022 00:48
-
-
Save Nixinova/a11c696cd4926aad58f473dbde11b3ae to your computer and use it in GitHub Desktop.
Discord Python bot template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import random | |
import discord | |
from dotenv import load_dotenv | |
load_dotenv() | |
TOKEN = os.getenv('DISCORD_TOKEN') | |
client = discord.Client() | |
@client.event | |
async def on_ready(): | |
print(f'{client.user} has connected to Discord!') | |
@client.event | |
async def on_message(message): | |
content = message.content.lower() | |
if message.author == client.user: | |
return | |
elif 'bad bot' in content: | |
replies = [ | |
"Don't be mean :(", | |
"Bad human", | |
] | |
reply = random.choice(replies) | |
await message.channel.send(reply) | |
client.run(TOKEN) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[source]] | |
url = "https://pypi.org/simple" | |
verify_ssl = true | |
name = "pypi" | |
[packages] | |
"discord.py" = "*" | |
python-dotenv = "*" | |
[dev-packages] | |
[requires] | |
python_version = "3.9" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment