Skip to content
This repository was archived by the owner on Apr 12, 2021. It is now read-only.
8 changes: 6 additions & 2 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ def __init__(self, *args, **kwargs):
self.command_messages = {}
self.messages_seen = 0
self.remove_command('help')

self.commands_ran = 0

async def on_message(self, ctx):
self.messages_seen += 1
await self.process_commands(ctx)

async def on_command(self, ctx):
self.commands_ran +=1

def __del__(self):
self.loop.set_exception_handler(lambda *args, **kwargs: None)
async def on_command_error(self, ctx, e):
Expand Down Expand Up @@ -121,4 +125,4 @@ def die(self):
self.loop.run_forever()
tasks.exception()
except Exception as e:
print(e)
print(e)
51 changes: 2 additions & 49 deletions mods/fun.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import discord
import request
import random
import requests
import aiohttp
import os
from discord.ext import commands
Expand Down Expand Up @@ -150,19 +150,7 @@ def __init__(self, bot):
'https://s-media-cache-ak0.pinimg.com/originals/69/fc/82/69fc828893e612d86fc7bb85862be96e.gif', 'http://25.media.tumblr.com/c65a4af4ff032d1ca06350b66a1e819c/tumblr_mtxk6zVzaa1sogk1do1_r1_500.gif',
'http://media.giphy.com/media/ROF8OQvDmxytW/giphy.gif', 'http://media.giphy.com/media/QUKkvRTIYLgMo/giphy.gif', 'http://media.tumblr.com/tumblr_mdaindozZF1ryvbtl.gif',
'https://31.media.tumblr.com/b307cca19d29eb1625bd841e661c0f59/tumblr_mvjhgmknl91stfs7go1_500.gif', 'http://media1.giphy.com/media/4pk6ba2LUEMi4/giphy.gif']

#
self.filt = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890$-_.+!*'(),"

#
def url_encode(word):
url = ""
for c in word:
if c not in self.filt:
url += "%" + str(hex(ord(c))).replace("0x", "")
else:
url += c
return url


@commands.command(name='pay')
async def payuser(self, ctx, who:discord.User=None, amount=None):
Expand Down Expand Up @@ -474,40 +462,5 @@ async def killcmd(self, ctx, *, user:str=None):
await ctx.send(embed=emb)


@commands.command(name='urban',
description= "search urban dictionary for definitions",
brief = "Search Urban Dictionary",
aliases= ['ud'])
async def urban(self, ctx, *, word: str=None):
search = word[0]
url = "http://api.urbandictionary.com/v0/define"
with aiohttp.ClientSession() as session:
async with session.get(url, params={"term": search}) as resp:
data = await resp.json()

if data["list"]:
entry = data["list"][0]
emb = Embeds.create_embed(self, ctx, "Urban Dictionary", None, None)
emb.add_field(name="Search", value="**{e[word]}**", inline=True)
emb.add_field(name="Result", value="**{e[definition]}**", inline=True)
emb.add_field(name="Example", value="**{e[example]}**", inline=True)
else:
emb = Embeds.create_embed(self, ctx, "Error!", None, None)
emb.add_field(name="Search Error", value="I couldn't find anything for **{e[word]}. I'm so sorry!", inline=True)
emb.set_footer(text="Requested by {0}".format(ctx.message.author), icon_url=ctx.message.author.avatar_url)
emb.timestamp = ctx.message.created_at
await ctx.send(embed=emb)

@commands.command(name="ascii",
description='Convert your text to ascii art!',
brief="Ascii art")
async def ascii(self, ctx, *, text: str=None):
url = "http://artii.herokuapp.com/make?text="
if text:
word = url_encode(text)
response = urllib.request.urlopen('http://artii.herokuapp.com/make?text=' + word)
text = str(response.read())
await ctx.send('```%s```' % text)

def setup(bot):
bot.add_cog(Fun(bot))
6 changes: 5 additions & 1 deletion mods/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, bot):
@commands.command(name='ping',
description="Ping!",
brief="Ping!",
aliases=['Ping', 'Ping!', 'Pong', 'Pong!', 'Latency', 'Test'])
aliases=['Ping', 'Ping!', 'Pong', 'Pong!', 'Latency', 'Test', 'test'])
async def ping(self, ctx):
emb = Embeds.create_embed(self, ctx, "Bot Latency", None, None)
latency = str(math.ceil(self.bot.latency * 1000))
Expand All @@ -43,10 +43,13 @@ async def createdat(self, ctx, id:int):
async def stats(self, ctx):
ping = math.floor(self.bot.latency * 1000)
prefix = self.bot.config.prefix
if prefix == "":
prefix = "None"
owner = self.bot.appinfo.owner
info = discord.__version__
servers = len(self.bot.guilds)
messages_seen = str(self.bot.messages_seen)
commands_ran = str(self.bot.commands_ran)
members = sum([member.bot != True for member in self.bot.get_all_members()])
bots = sum([member.bot == True for member in self.bot.get_all_members()])
channels = len(list(self.bot.get_all_channels()))
Expand Down Expand Up @@ -78,6 +81,7 @@ async def stats(self, ctx):
embed.add_field(name="Bot prefix", value=prefix, inline=True)
embed.add_field(name="Servers", value=servers, inline=True)
embed.add_field(name="Messages seen", value=messages_seen, inline=True)
embed.add_field(name="Commands ran", value=commands_ran, inline=True)
embed.add_field(name="Users", value=members, inline=True)
embed.add_field(name="Bots", value=bots, inline=True)
embed.add_field(name="Channels", value=channels, inline=True)
Expand Down
35 changes: 15 additions & 20 deletions mods/reminders.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import asyncio
import time
import logging
import typing
import utils
from utils.embed import Embeds

Expand All @@ -23,25 +24,19 @@ def __init__(self, bot):
self.units = {"second" : 1,"minute": 60, "hour": 3600, "day": 86400, "week": 604800, "month": 2592000, "year": 31104000}

@commands.command(pass_context=True)
async def remind(self, ctx, who : str=None, quantity : int=None, time_unit : str=None, *, text : str=None):
async def remind(self, ctx, who : typing.Union[discord.Member, str], quantity : int, time_unit : str, *, text : str):
"""Sends you <text> when the time is up
Accepts: minutes, hours, days, weeks, month
Example:
remind me 3 days Have sushi with Asu and JennJenn"""
time_unit = time_unit.lower()
author = ctx.message.author
s = ""
if who:
if who == 'me':
who = author
else:
if who[0:2] == "<@" and who[-1] == ">":
who = int(re.sub("[^0-9]", "", who))
who = self.bot.get_user(who)
who = user.name
if not who:
if who == "me" or who == 'myself':
who = author

elif type(who) == str:
await ctx.send("Invalid user. Choose; mention, server nickname, id, or use remind me/myself if reminding yourself.")
return
if time_unit.endswith("s"):
time_unit = time_unit[:-1]
s = "s"
Expand All @@ -68,22 +63,22 @@ async def unremind(self, ctx, target: int=None):
author = ctx.message.author
to_remove = []
if target:
for a, reminder in enumerate(self.reminders, 1):
if target == a and reminder["AUTHOR"] == ctx.message.author.id:
to_remove.append(reminder)
for a, b in enumerate(self.reminders, 1):
if b["AUTHOR"] == author.id and target == a:
to_remove.append(b)
else:
for reminder in self.reminders:
if reminder["AUTHOR"] == ctx.message.author.id:
to_remove.append(reminder)
for b in self.reminders:
if b["AUTHOR"] == ctx.message.author.id:
to_remove.append(b)

if not to_remove == []:
for reminder in to_remove:
self.reminders.remove(reminder)
for b in to_remove:
self.reminders.remove(b)
fileIO("data/reminders.json", "save", self.reminders)
if not target:
await ctx.send("All your notifications have been removed.")
else:
await ctx.send("{} has been removed from your reminders".format(target))
await ctx.send("{} has been removed from your reminders".format(b["TEXT"]))
else:
await ctx.send("You don't have any upcoming notification.")

Expand Down