Last active
December 1, 2021 11:46
-
-
Save nhatzHK/648fb2a0e49efed0db57374fecc6d83e to your computer and use it in GitHub Desktop.
Boilerplate for discord bot with python/discord.py
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
{ | |
"prefix" : "::", | |
"token" : "get your token from discord" | |
} |
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
# Bot boilerplate with discord.py (legacy, not rewrite) | |
import discord # install discord.py before hand | |
import asyncio | |
import json | |
import logging | |
# Uncommment this for voice support | |
#discord.opus.load_opus('/usr/lib/libopus.so.0.6.1') | |
# Create the file named config.json | |
# and add the necessary info in it | |
# and place it in the same directory as this file | |
config = dict() | |
try: | |
with open ('config.json') as con_file: | |
config = json.load (con_file) | |
except: | |
print('Uh oh!') | |
exit(42) | |
logging.basicConfig (level = logging.INFO) | |
Bot = discord.Client() | |
@Bot.event | |
async def on_ready (): | |
print('Ready.') | |
@Bot.event | |
async def on_message (message): | |
pass | |
Bot.run (config['token']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment