Skip to content

Instantly share code, notes, and snippets.

@nhatzHK
Last active December 1, 2021 11:46
Show Gist options
  • Save nhatzHK/648fb2a0e49efed0db57374fecc6d83e to your computer and use it in GitHub Desktop.
Save nhatzHK/648fb2a0e49efed0db57374fecc6d83e to your computer and use it in GitHub Desktop.
Boilerplate for discord bot with python/discord.py
{
"prefix" : "::",
"token" : "get your token from discord"
}
# 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