Skip to content

Instantly share code, notes, and snippets.

@Bert-Macklin
Bert-Macklin / bot.py
Last active March 25, 2018 19:17
Making a Discord Bot in Python 3
# bot.py
import discord
# create discord client
client = discord.Client()
# token from https://discordapp.com/developers
token = 'NDI3MjIyOTExMjg0NDEyNDQ2.DZhfMA.h3sx9iq6vO_ROYtlxHHTSZJz0xs'
# bot is ready
@Bert-Macklin
Bert-Macklin / command_example.py
Last active March 25, 2018 02:48
Making a Discord Bot in Python 3
# command's function
def hello_function(message,client,args):
try:
return 'Hello {}, Argument One: {}'.format(message.author, args[0])
except Exception as e:
return e
# hello command dictionary
hello_command = {
# if the string starts with this the function will be called
@Bert-Macklin
Bert-Macklin / command_handler.py
Last active March 25, 2018 05:08
Making a Discord Bot in Python 3
# command handler class
class CommandHandler:
# on object creation take in the client variable
def __init__(self, client):
self.client = client
# create an array to store commands
self.commands = []
@Bert-Macklin
Bert-Macklin / bot.py
Last active September 19, 2018 18:15
Making a Discord Bot in Python 3
# bot.py
import discord
# command handler class
class CommandHandler:
# constructor
def __init__(self, client):
@Bert-Macklin
Bert-Macklin / bot.py
Last active December 30, 2020 12:10
Making a Discord Bot in Python 3
# bot.py
import discord
import requests
import json
# command handler class
class CommandHandler:
# constructor