From 9d4db194a1deefea20551f6934a8ae84595e6695 Mon Sep 17 00:00:00 2001 From: AutumnClove Date: Wed, 3 Jun 2020 16:28:59 -0500 Subject: [PATCH 01/10] added a commands ran, catch no prefix in stats to prevent error using stats, fix reminders. --- bot.py | 8 ++++++-- mods/info.py | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index 38a20de..dd4641e 100644 --- a/bot.py +++ b/bot.py @@ -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): @@ -121,4 +125,4 @@ def die(self): self.loop.run_forever() tasks.exception() except Exception as e: - print(e) \ No newline at end of file + print(e) diff --git a/mods/info.py b/mods/info.py index 802655f..778558f 100644 --- a/mods/info.py +++ b/mods/info.py @@ -47,6 +47,7 @@ async def stats(self, ctx): 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())) @@ -75,9 +76,10 @@ async def stats(self, ctx): embed.add_field(name="Owner", value=owner, inline=True) embed.add_field(name="Ping", value=str(ping) + ' ms', inline=True) embed.add_field(name="Discord.py version", value=info, inline=True) - embed.add_field(name="Bot prefix", value=prefix, inline=True) + embed.add_field(name="Bot prefix", value="There is none, just type a command", 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) From 8a6971054470ccb70d657a9c188f5b925c4bc139 Mon Sep 17 00:00:00 2001 From: AutumnClove Date: Wed, 3 Jun 2020 16:29:55 -0500 Subject: [PATCH 02/10] added a commands ran, catch no prefix in stats, fix reminders --- mods/info.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mods/info.py b/mods/info.py index 778558f..d332382 100644 --- a/mods/info.py +++ b/mods/info.py @@ -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)) @@ -43,6 +43,8 @@ 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) @@ -76,7 +78,7 @@ async def stats(self, ctx): embed.add_field(name="Owner", value=owner, inline=True) embed.add_field(name="Ping", value=str(ping) + ' ms', inline=True) embed.add_field(name="Discord.py version", value=info, inline=True) - embed.add_field(name="Bot prefix", value="There is none, just type a command", inline=True) + 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) From f259d3105bac995c896e25546a27e8f465acc1f8 Mon Sep 17 00:00:00 2001 From: AutumnClove Date: Wed, 3 Jun 2020 16:31:58 -0500 Subject: [PATCH 03/10] fix reminders --- mods/reminders.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/mods/reminders.py b/mods/reminders.py index 4b832ef..841497e 100644 --- a/mods/reminders.py +++ b/mods/reminders.py @@ -11,6 +11,7 @@ import asyncio import time import logging +import typing import utils from utils.embed import Embeds @@ -23,7 +24,7 @@ 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 when the time is up Accepts: minutes, hours, days, weeks, month Example: @@ -31,16 +32,10 @@ async def remind(self, ctx, who : str=None, quantity : int=None, time_unit : str 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": who = author + if not who: + await ctx.send("Invalid user. Choose a ID, mention, nickname, or say me") if time_unit.endswith("s"): time_unit = time_unit[:-1] From 6269bf62dadd1f156d2d57cfbd268b87000529ae Mon Sep 17 00:00:00 2001 From: AutumnClove Date: Wed, 3 Jun 2020 20:43:55 -0500 Subject: [PATCH 04/10] getting closer --- mods/reminders.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mods/reminders.py b/mods/reminders.py index 841497e..1500aa3 100644 --- a/mods/reminders.py +++ b/mods/reminders.py @@ -25,8 +25,7 @@ def __init__(self, bot): @commands.command(pass_context=True) async def remind(self, ctx, who : typing.Union[discord.Member, str], quantity : int, time_unit : str, *, text : str): - """Sends you when the time is up - Accepts: minutes, hours, days, weeks, month + """Sends you 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() @@ -34,9 +33,9 @@ async def remind(self, ctx, who : typing.Union[discord.Member, str], quantity : s = "" if who == "me": who = author - if not who: - await ctx.send("Invalid user. Choose a ID, mention, nickname, or say me") - + elif who == str and str != who: + await ctx.send("Invalid user. Choos; mention, server nickname, id, or use remind me if remindin yourself.") + return if time_unit.endswith("s"): time_unit = time_unit[:-1] s = "s" From f4bb318cd021f818d7cdbc7063c3ba258b109813 Mon Sep 17 00:00:00 2001 From: AutumnClove Date: Wed, 3 Jun 2020 21:31:29 -0500 Subject: [PATCH 05/10] pushing so I can copy paste --- mods/reminders.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/reminders.py b/mods/reminders.py index 1500aa3..4e0c98f 100644 --- a/mods/reminders.py +++ b/mods/reminders.py @@ -33,8 +33,8 @@ async def remind(self, ctx, who : typing.Union[discord.Member, str], quantity : s = "" if who == "me": who = author - elif who == str and str != who: - await ctx.send("Invalid user. Choos; mention, server nickname, id, or use remind me if remindin yourself.") + if who == str: + await ctx.send("Invalid user. Choose; mention, server nickname, id, or use remind me if remindin yourself.") return if time_unit.endswith("s"): time_unit = time_unit[:-1] From c714edea1c4d6abc92c24354b3b97cfc13ed8d1f Mon Sep 17 00:00:00 2001 From: AutumnClove Date: Wed, 3 Jun 2020 22:23:08 -0500 Subject: [PATCH 06/10] reminders finally fixed. tmr ascii and ud --- mods/reminders.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/reminders.py b/mods/reminders.py index 4e0c98f..3442c5f 100644 --- a/mods/reminders.py +++ b/mods/reminders.py @@ -33,7 +33,7 @@ async def remind(self, ctx, who : typing.Union[discord.Member, str], quantity : s = "" if who == "me": who = author - if who == str: + if type(who) == str: await ctx.send("Invalid user. Choose; mention, server nickname, id, or use remind me if remindin yourself.") return if time_unit.endswith("s"): From 4ba491547138570fb7b119d17eaaa1a6dc615c96 Mon Sep 17 00:00:00 2001 From: AutumnClove Date: Wed, 3 Jun 2020 23:17:42 -0500 Subject: [PATCH 07/10] add myself, change to elif, fix broken line. Alea said there's a bettet way to do this, but this works fine for me so.... --- mods/reminders.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mods/reminders.py b/mods/reminders.py index 3442c5f..64be3d5 100644 --- a/mods/reminders.py +++ b/mods/reminders.py @@ -25,16 +25,17 @@ def __init__(self, bot): @commands.command(pass_context=True) async def remind(self, ctx, who : typing.Union[discord.Member, str], quantity : int, time_unit : str, *, text : str): - """Sends you when the time is up Accepts: minutes, hours, days, weeks, month + """Sends you 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 == "me": + if who == "me" or who == 'myself': who = author - if type(who) == str: - await ctx.send("Invalid user. Choose; mention, server nickname, id, or use remind me if remindin yourself.") + elif type(who) == str: + await ctx.send("Invalid user. Choose; mention, server nickname, id, or use remind me/myself if remindin yourself.") return if time_unit.endswith("s"): time_unit = time_unit[:-1] From 2031401a7f56882f0134edb2a437da0f2c1a9e9c Mon Sep 17 00:00:00 2001 From: AutumnClove Date: Thu, 4 Jun 2020 08:52:10 -0500 Subject: [PATCH 08/10] remove ud and ascii till I get a pc --- mods/fun.py | 51 ++------------------------------------------------- 1 file changed, 2 insertions(+), 49 deletions(-) diff --git a/mods/fun.py b/mods/fun.py index 789bb73..6d11fa0 100644 --- a/mods/fun.py +++ b/mods/fun.py @@ -1,6 +1,6 @@ import discord +import request import random -import requests import aiohttp import os from discord.ext import commands @@ -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): @@ -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)) From acf11f7d3a675ae1b80f7402f7bfec7238ae410a Mon Sep 17 00:00:00 2001 From: AutumnClove Date: Thu, 2 Jul 2020 13:30:23 -0500 Subject: [PATCH 09/10] Fix for reminders removal next support for multiple time inputs --- mods/reminders.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mods/reminders.py b/mods/reminders.py index 64be3d5..d77889d 100644 --- a/mods/reminders.py +++ b/mods/reminders.py @@ -63,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.") From 095509d50f69779a619d68299dd6447e0973e5ae Mon Sep 17 00:00:00 2001 From: AutumnClove Date: Tue, 7 Jul 2020 09:24:14 -0500 Subject: [PATCH 10/10] typo --- mods/reminders.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/reminders.py b/mods/reminders.py index d77889d..f5cb8b7 100644 --- a/mods/reminders.py +++ b/mods/reminders.py @@ -35,7 +35,7 @@ async def remind(self, ctx, who : typing.Union[discord.Member, str], quantity : 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 remindin yourself.") + 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]