Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Python Simple Discord Bot
import discord
from discord.ext import commands
import datetime
from urllib import parse, request
import re
bot = commands.Bot(command_prefix='>', description="This is a Helper Bot")
async def ping(ctx):
await ctx.send('pong')
async def sum(ctx, numOne: int, numTwo: int):
await ctx.send(numOne + numTwo)
async def info(ctx):
embed = discord.Embed(title=f"{}", description="Lorem Ipsum asdasd", timestamp=datetime.datetime.utcnow(),
embed.add_field(name="Server created at", value=f"{ctx.guild.created_at}")
embed.add_field(name="Server Owner", value=f"{ctx.guild.owner}")
embed.add_field(name="Server Region", value=f"{ctx.guild.region}")
embed.add_field(name="Server ID", value=f"{}")
# embed.set_thumbnail(url=f"{ctx.guild.icon}")
await ctx.send(embed=embed)
async def youtube(ctx, *, search):
query_string = parse.urlencode({'search_query': search})
html_content = request.urlopen('' + query_string)
# print(
search_results = re.findall('href=\"\\/watch\\?v=(.{11})',
# I will put just the first result, you can loop the response to show more results
await ctx.send('' + search_results[0])
# Events
async def on_ready():
await bot.change_presence(activity=discord.Streaming(name="Tutorials", url=""))
print('My Ready is Body')
async def on_message(message):
if "tutorial" in message.content.lower():
# in this case don't respond with the word "Tutorial" or you will call the on_message event recursively
await'This is that you want')
await bot.process_commands(message)'token')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.