Skip to content

Instantly share code, notes, and snippets.

View ericjaychi's full-sized avatar
💻

Eric Chi ericjaychi

💻
View GitHub Profile
# IMPORT DISCORD.PY. ALLOWS ACCESS TO DISCORD'S API.
import discord
# GETS THE CLIENT OBJECT FROM DISCORD.PY. CLIENT IS SYNONYMOUS WITH BOT.
bot = discord.Client()
# EVENT LISTENER FOR WHEN THE BOT HAS SWITCHED FROM OFFLINE TO ONLINE.
@bot.event
async def on_ready():
# CREATES A COUNTER TO KEEP TRACK OF HOW MANY GUILDS / SERVERS THE BOT IS CONNECTED TO.
# Import the os module.
import os
# Import load_dotenv function from dotenv module.
from dotenv import load_dotenv
# Loads the .env file that resides on the same level as the script.
load_dotenv()
# Grab the API token from the .env file.
DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
# IMPORT DISCORD.PY. ALLOWS ACCESS TO DISCORD'S API.
import discord
# IMPORT THE OS MODULE.
import os
# IMPORT LOAD_DOTENV FUNCTION FROM DOTENV MODULE.
from dotenv import load_dotenv
# LOADS THE .ENV FILE THAT RESIDES ON THE SAME LEVEL AS THE SCRIPT.
# IMPORT DISCORD.PY. ALLOWS ACCESS TO DISCORD'S API.
import discord
# IMPORT THE OS MODULE.
import os
# IMPORT LOAD_DOTENV FUNCTION FROM DOTENV MODULE.
from dotenv import load_dotenv
# IMPORT COMMANDS FROM THE DISCORD.EXT MODULE.
@bot.command()
async def print(ctx, *args):
response = ""
for arg in args:
response = response + " " + arg
await ctx.channel.send(response)
@bot.command(
help="Uses come crazy logic to determine if pong is actually the correct value or not.",
brief="Prints pong back to the channel."
)
async def ping(ctx):
await ctx.channel.send("pong")
@bot.command(
help="Looks like you need some help.",
brief="Prints the list of values back to the channel."
@bot.event
async def on_message(message):
if message.content == "hello":
await message.channel.send("pies are better than cakes. change my mind.")
@bot.event
async def on_message(message):
if message.content == "hello":
await message.channel.send("pies are better than cakes. change my mind.")
await bot.process_commands(message)
{"lastUpload":"2020-08-08T05:04:10.070Z","extensionVersion":"v3.4.3"}
# IMPORT DISCORD.PY. ALLOWS ACCESS TO DISCORD'S API.
import discord
# IMPORT THE OS MODULE.
import os
# IMPORT LOAD_DOTENV FUNCTION FROM DOTENV MODULE.
from dotenv import load_dotenv
# IMPORT COMMANDS FROM THE DISCORD.EXT MODULE.