From baeca8f58ca563bb0f532e2f26f328d4a9fe718c Mon Sep 17 00:00:00 2001 From: Benjamin O'Brien Date: Sat, 22 Aug 2020 22:28:49 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20Prism=201.3=20Patch=20?= =?UTF-8?q?=F0=9F=A9=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/prism.py | 10 ++++- assets/res/plain-text/update.txt | 4 -- commands/currency/balance.py | 14 ++----- commands/currency/bank.py | 2 - commands/currency/beg.py | 6 +-- commands/currency/bet.py | 2 - commands/currency/buy.py | 2 - commands/currency/daily.py | 2 - commands/currency/deposit.py | 2 - commands/currency/inventory.py | 11 +----- commands/currency/lottery.py | 2 - commands/currency/pay.py | 6 +-- commands/currency/premium.py | 2 +- commands/currency/rob.py | 10 +---- commands/currency/shop.py | 2 - commands/currency/sock.py | 10 +---- commands/currency/withdraw.py | 2 - commands/currency/work.py | 2 - commands/entertainment/sue.py | 2 - commands/entertainment/sun.py | 2 - commands/entertainment/trigger.py | 2 - commands/entertainment/tts.py | 8 ++-- commands/entertainment/unicorn.py | 2 - commands/entertainment/use.py | 56 +--------------------------- commands/entertainment/weirdtext.py | 2 - commands/misc/bio.py | 4 +- commands/misc/changelog.py | 32 ---------------- commands/misc/covid.py | 6 +-- commands/misc/credits.py | 2 - commands/misc/deleted.py | 38 +++++++++---------- commands/misc/help.py | 35 ++++------------- commands/misc/invite.py | 2 - commands/misc/leaderboard.py | 2 - commands/misc/math.py | 2 - commands/misc/pet.py | 14 +------ commands/misc/ping.py | 2 - commands/misc/profile.py | 14 +++---- commands/misc/question.py | 2 - commands/misc/server.py | 2 - commands/misc/settings.py | 18 ++------- commands/misc/shorten.py | 2 - commands/misc/stats.py | 4 +- commands/misc/uptime.py | 2 - commands/misc/user.py | 18 ++------- commands/misc/vote.py | 2 - commands/moderation/ban.py | 2 - commands/moderation/clearwarnings.py | 2 - commands/moderation/kick.py | 2 - commands/moderation/makerole.py | 2 - commands/moderation/mute.py | 2 - commands/moderation/purge.py | 2 - commands/moderation/randomban.py | 2 - commands/moderation/randomkick.py | 2 - commands/moderation/tempban.py | 2 - commands/moderation/unmute.py | 2 - commands/moderation/warn.py | 2 - commands/moderation/warnings.py | 2 - commands/pets/adopt.py | 2 - commands/pets/fight.py | 2 - commands/pets/hold.py | 2 - commands/pets/name.py | 2 - commands/pets/shelter.py | 2 - commands/pets/takeback.py | 2 - commands/pets/train.py | 2 - 64 files changed, 67 insertions(+), 339 deletions(-) delete mode 100644 assets/res/plain-text/update.txt delete mode 100644 commands/misc/changelog.py diff --git a/assets/prism.py b/assets/prism.py index 2775ac5..78c1d04 100644 --- a/assets/prism.py +++ b/assets/prism.py @@ -118,6 +118,10 @@ async def error_handler(ctx, error): pass + elif "NoSuchUser" in str(error): + + return + await ctx.send(embed = discord.Embed(title = "Unexpected Error", description = "The command you just used generated an unexpected error.\nPrism has sent an automatic bug report about this problem.\n\nIn the meantime, try some of our other commands. :)", color = 0xFF0000)) base = ctx.message.content.split(" ")[0] if " " in ctx.message.content else ctx.message.content @@ -408,7 +412,7 @@ def bought(name, amount): return embed - def getClosestUser(ctx, user, return_member = False): + async def getClosestUser(ctx, user, return_member = False): if ctx.author.id == user.id: @@ -460,7 +464,9 @@ def getClosestUser(ctx, user, return_member = False): if not matches: - return await ctx.send(embed = Tools.error("Couldn't find that user.")) + await ctx.send(embed = Tools.error("Couldn't find that user.")) + + raise AttributeError("NoSuchUser") id = int(max(matches.items(), key = itemgetter(1))[0]) diff --git a/assets/res/plain-text/update.txt b/assets/res/plain-text/update.txt deleted file mode 100644 index 2da9abf..0000000 --- a/assets/res/plain-text/update.txt +++ /dev/null @@ -1,4 +0,0 @@ -{ - "jumpurl": "https://discordapp.com/channels/729513002302177311/729760209223942165/735974931254345819", - "content": "-clear 4" -} \ No newline at end of file diff --git a/commands/currency/balance.py b/commands/currency/balance.py index 85ab72c..edced2b 100644 --- a/commands/currency/balance.py +++ b/commands/currency/balance.py @@ -20,19 +20,11 @@ async def balance(self, ctx, user: str = None): db = loads(open("db/users", "r").read()) - if not user: - - user = ctx.author.name + "#" + str(ctx.author.discriminator) - - user = Tools.getClosestUser(ctx, user) - - if not user: - - return await ctx.send(embed = Tools.error(f"I couldn't find that user; try again with more letters.")) + user = await Tools.getClosestUser(ctx, user if user else ctx.author) - elif not str(user.id) in db: + if not str(user.id) in db: - return await ctx.send(embed = Tools.error(f"{user.name} doesn't have an account.")) + return await ctx.send(embed = Tools.error(f"{user.name} doesn't have a Prism account.")) _user = db[str(user.id)] diff --git a/commands/currency/bank.py b/commands/currency/bank.py index d886901..cf65cdc 100644 --- a/commands/currency/bank.py +++ b/commands/currency/bank.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from json import loads, dumps diff --git a/commands/currency/beg.py b/commands/currency/beg.py index 24e30a2..e8a0d0d 100644 --- a/commands/currency/beg.py +++ b/commands/currency/beg.py @@ -34,11 +34,7 @@ async def beg(self, ctx, member: str = None): if member: - member = Tools.getClosestUser(ctx, member) - - if not member: - - return await ctx.send(embed = Tools.error(f"I couldn't find that user; try again with more letters.")) + member = await Tools.getClosestUser(ctx, member) user = member.name diff --git a/commands/currency/bet.py b/commands/currency/bet.py index 39ea3f4..ee82f16 100644 --- a/commands/currency/bet.py +++ b/commands/currency/bet.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from random import randint diff --git a/commands/currency/buy.py b/commands/currency/buy.py index bb54567..fd7083e 100644 --- a/commands/currency/buy.py +++ b/commands/currency/buy.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules from asyncio import sleep from json import loads, dumps diff --git a/commands/currency/daily.py b/commands/currency/daily.py index 76488ac..28ba271 100644 --- a/commands/currency/daily.py +++ b/commands/currency/daily.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from json import loads, dumps diff --git a/commands/currency/deposit.py b/commands/currency/deposit.py index 71651a3..8ff832f 100644 --- a/commands/currency/deposit.py +++ b/commands/currency/deposit.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from json import loads, dumps diff --git a/commands/currency/inventory.py b/commands/currency/inventory.py index 3295815..3f0c1b1 100644 --- a/commands/currency/inventory.py +++ b/commands/currency/inventory.py @@ -18,16 +18,7 @@ def __init__(self, bot): @commands.command(aliases = ["inv"]) async def inventory(self, ctx, user = None): - if not user: - - user = ctx.author.name + "#" + str(ctx.author.discriminator) - - user = Tools.getClosestUser(ctx, user) - - if not user: - - return await ctx.send(embed = Tools.error(f"I couldn't find that user; try again with more letters.")) - + user = await Tools.getClosestUser(ctx, user if user else ctx.author) db = loads(open("db/users", "r").read()) diff --git a/commands/currency/lottery.py b/commands/currency/lottery.py index 5a16249..f669e38 100644 --- a/commands/currency/lottery.py +++ b/commands/currency/lottery.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from random import randint diff --git a/commands/currency/pay.py b/commands/currency/pay.py index 809fdea..3023ea5 100644 --- a/commands/currency/pay.py +++ b/commands/currency/pay.py @@ -28,11 +28,7 @@ async def pay(self, ctx, user = None, amount = None): user = Tools.getClosestUser(ctx, user) - if not user: - - return await ctx.send(embed = Tools.error(f"I couldn't find that user; try again with more letters.")) - - elif user.id == ctx.author.id: + if user.id == ctx.author.id: return await ctx.send(embed = Tools.error("No paying yourself. >:C")) diff --git a/commands/currency/premium.py b/commands/currency/premium.py index cf1e0c1..bd4a2a5 100644 --- a/commands/currency/premium.py +++ b/commands/currency/premium.py @@ -16,7 +16,7 @@ def __init__(self, bot): self.usage = "premium" @commands.command(aliases = ["upgrade"]) - async def premium(self, ctx, *, sentence: str = None): + async def premium(self, ctx): db = loads(open("db/users", "r").read()) diff --git a/commands/currency/rob.py b/commands/currency/rob.py index 8e75a07..1d12fec 100644 --- a/commands/currency/rob.py +++ b/commands/currency/rob.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import random import discord @@ -28,13 +26,9 @@ async def rob(self, ctx, user = None): return await ctx.send(embed = Tools.error("Please specify somebody to rob.")) - user = Tools.getClosestUser(ctx, user) - - if not user: - - return await ctx.send(embed = Tools.error(f"I couldn't find that user; try again with more letters.")) + user = await Tools.getClosestUser(ctx, user) - elif user.id == ctx.author.id: + if user.id == ctx.author.id: return await ctx.send(embed = Tools.error("Stop trying to rob yourself.")) diff --git a/commands/currency/shop.py b/commands/currency/shop.py index 3e13c72..fe1250b 100644 --- a/commands/currency/shop.py +++ b/commands/currency/shop.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from json import loads diff --git a/commands/currency/sock.py b/commands/currency/sock.py index 0e92e6b..96466ad 100644 --- a/commands/currency/sock.py +++ b/commands/currency/sock.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from random import randint @@ -18,7 +16,7 @@ def __init__(self, bot): self.usage = "sock [user]" @commands.command() - async def sock(self, ctx, user: str = None): + async def sock(self, ctx, user = None): if Cooldowns.on_cooldown(ctx, "sock"): @@ -26,14 +24,10 @@ async def sock(self, ctx, user: str = None): elif not user: - return await ctx.send(embed = Tools.error("I need to know who your trying to sock.")) + return await ctx.send(embed = Tools.error("No user specified to sock.")) user = Tools.getClosestUser(ctx, user) - if not user: - - return await ctx.send(embed = Tools.error(f"I couldn't find that user; try again with more letters.")) - db = loads(open("db/users", "r").read()) if user.id == ctx.author.id: diff --git a/commands/currency/withdraw.py b/commands/currency/withdraw.py index d3fba01..072db89 100644 --- a/commands/currency/withdraw.py +++ b/commands/currency/withdraw.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from json import loads, dumps diff --git a/commands/currency/work.py b/commands/currency/work.py index bde0df6..69c24ab 100644 --- a/commands/currency/work.py +++ b/commands/currency/work.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from json import loads, dumps diff --git a/commands/entertainment/sue.py b/commands/entertainment/sue.py index f5c2118..a4dd5d8 100644 --- a/commands/entertainment/sue.py +++ b/commands/entertainment/sue.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from random import randint diff --git a/commands/entertainment/sun.py b/commands/entertainment/sun.py index d5746ce..997423c 100644 --- a/commands/entertainment/sun.py +++ b/commands/entertainment/sun.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from random import choice diff --git a/commands/entertainment/trigger.py b/commands/entertainment/trigger.py index b803673..f5774ad 100644 --- a/commands/entertainment/trigger.py +++ b/commands/entertainment/trigger.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from json import loads, dumps diff --git a/commands/entertainment/tts.py b/commands/entertainment/tts.py index a0d9c38..2ceabc6 100644 --- a/commands/entertainment/tts.py +++ b/commands/entertainment/tts.py @@ -1,6 +1,5 @@ -# Prism Rewrite - Basic Command - # Modules +from assets.prism import Tools from discord.ext import commands # Main Command Class @@ -10,14 +9,13 @@ def __init__(self, bot): self.bot = bot self.desc = "Make the bot speak" self.usage = "tts [text]" - self.tags = [] @commands.command(aliases = ["text2speech", "texttospeech", "speak", "speech"]) async def tts(self, ctx, *, sentence: str = None): if not sentence: - return await ctx.send("I can't speak if you don't give me anything to say. >:C") + return await ctx.send(embed = Tools.error("No text specified.")) try: @@ -25,7 +23,7 @@ async def tts(self, ctx, *, sentence: str = None): except: - return await ctx.send("I don't have permission to send TTS messages.") + return await ctx.send(embed = Tools.error("Missing permissions to send TTS messages.")) # Link to bot def setup(bot): diff --git a/commands/entertainment/unicorn.py b/commands/entertainment/unicorn.py index f40ff4f..cbf9332 100644 --- a/commands/entertainment/unicorn.py +++ b/commands/entertainment/unicorn.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from json import loads diff --git a/commands/entertainment/use.py b/commands/entertainment/use.py index bb8e323..f6f2c42 100644 --- a/commands/entertainment/use.py +++ b/commands/entertainment/use.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from random import randint @@ -24,59 +22,7 @@ async def use(self, ctx, item: str = None): return await ctx.send(embed = Tools.error("No item specified to use.")) - return await ctx.send("wip") - - user = Tools.getClosestUser(ctx, user) - - if not user: - - return await ctx.send(embed = Tools.error("Yea I don't think that's an actual person.")) - - db = loads(open("db/users", "r").read()) - - _user = db[str(ctx.author.id)] - - __user = db[str(user.id)] - - inventory = _user["data"]["inventory"] - - if not "Hotdog" in inventory: - - return await ctx.send(embed = Tools.error("You don't have any hotdogs! Buy some with the ``shop`` command.")) - - inventory["Hotdog"]["count"] -= 1 - - if inventory["Hotdog"]["count"] == 0: - - inventory.pop("Hotdog") - - if randint(1, 2) == 1: - - amt = randint(100, 1000) - - _user["balance"] += amt - - __user["balance"] -= amt - - else: - - amt = None - - open("db/users", "w").write(dumps(db, indent = 4)) - - if amt: - - embed = discord.Embed(title = f"You just threw your hotdog at {user.name}!", description = f"They dropped {amt} coins!", color = 0x126bf1) - - else: - - embed = discord.Embed(title = "Woops! Your hotdog missed! oh no :(", color = 0x126bf1) - - embed.set_author(name = " | Hotdog", icon_url = self.bot.user.avatar_url) - - embed.set_footer(text = f" | Requested by {ctx.author}.", icon_url = ctx.author.avatar_url) - - return await ctx.send(embed = embed) + return await ctx.send(embed = Tools.error("This command is coming in `v1.4`.")) # Link to bot def setup(bot): diff --git a/commands/entertainment/weirdtext.py b/commands/entertainment/weirdtext.py index 09ad54f..4c1d90b 100644 --- a/commands/entertainment/weirdtext.py +++ b/commands/entertainment/weirdtext.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import random diff --git a/commands/misc/bio.py b/commands/misc/bio.py index 58c171a..15816ab 100644 --- a/commands/misc/bio.py +++ b/commands/misc/bio.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import json import discord @@ -24,7 +22,7 @@ async def biography(self, ctx, *, bio: str = None): elif len(bio) > 200: - return await ctx.send(embed = Tools.error("Your biography is way too long.")) + return await ctx.send(embed = Tools.error("You're biography is way too long.")) db = json.loads(open("db/users", "r").read()) diff --git a/commands/misc/changelog.py b/commands/misc/changelog.py deleted file mode 100644 index caf21b1..0000000 --- a/commands/misc/changelog.py +++ /dev/null @@ -1,32 +0,0 @@ -# Prism Rewrite - Basic Command - -# Modules -import json -import discord - -from discord.ext import commands - -# Main Command Class -class Changelog(commands.Cog): - - def __init__(self, bot): - self.bot = bot - self.desc = "Checks the bots changelog" - self.usage = "changelog" - - @commands.command(aliases = ["version", "cl", "updates", "update"]) - async def changelog(self, ctx): - - latest_update = json.loads(open("assets/res/plain-text/update.txt", "r").read()) - - if ctx.author in self.bot.get_guild(729513002302177311).members: - - message = f"Click here to check the changelog:\n{latest_update['jumpurl']}" - - return await ctx.send(message) - - return await ctx.send(embed = latest_update["content"]) - -# Link to bot -def setup(bot): - bot.add_cog(Changelog(bot)) diff --git a/commands/misc/covid.py b/commands/misc/covid.py index 11135b3..b21e78e 100644 --- a/commands/misc/covid.py +++ b/commands/misc/covid.py @@ -1,10 +1,10 @@ # Prism Rewrite - Basic Command # Modules -import json import discord +from json import loads -import requests +from requests import get from discord.ext import commands # Main Command Class @@ -20,7 +20,7 @@ def __init__(self, bot): @commands.command(aliases = ["corona"]) async def covid(self, ctx): - response = json.loads(requests.get(self.url).text) + response = loads(get(self.url).text) stats = f"""Active Cases (worldwide): {response["activeCases"]}\nClosed Cases (worldwide): {response["closedCases"]}\n\nTotal Cases (worldwide): {response["totalCases"]}\nRecovered (worldwide): {response["recovered"]}\nDeaths (worldwide): {response["deaths"]}\n\nLast update: {response["lastUpdate"]}""" diff --git a/commands/misc/credits.py b/commands/misc/credits.py index 8d2a0a8..c0e947a 100644 --- a/commands/misc/credits.py +++ b/commands/misc/credits.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from discord.ext import commands diff --git a/commands/misc/deleted.py b/commands/misc/deleted.py index 71cc7fd..d0daec0 100644 --- a/commands/misc/deleted.py +++ b/commands/misc/deleted.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import json import discord @@ -10,35 +8,35 @@ # Main Command Class class Deleted(commands.Cog): - def __init__(self, bot): - self.bot = bot - self.desc = "Lists the last 5 deleted messages" - self.usage = "deleted" + def __init__(self, bot): + self.bot = bot + self.desc = "Lists the last 5 deleted messages" + self.usage = "deleted" - @commands.command(aliases = ["messages", "delmes", "deletedmessages"]) - @commands.has_permissions(manage_messages = True) - async def deleted(self, ctx): + @commands.command(aliases = ["messages", "delmes", "deletedmessages"]) + @commands.has_permissions(manage_messages = True) + async def deleted(self, ctx): - db = json.loads(open("db/guilds", "r").read()) + db = json.loads(open("db/guilds", "r").read()) - messages = "" + messages = "" - for message in db[str(ctx.guild.id)]["data"]["deleted_messages"]: + for message in db[str(ctx.guild.id)]["data"]["deleted_messages"]: - messages = f"{messages}{message}\n" + messages = f"{messages}{message}\n" - if not messages: + if not messages: - return await ctx.send(embed = Tools.error("This server doesn't have any deleted messages.")) + return await ctx.send(embed = Tools.error("This server doesn't have any deleted messages.")) - embed = discord.Embed(description = messages, color = 0x126bf1) + embed = discord.Embed(description = messages, color = 0x126bf1) - embed.set_author(name = " | Deleted Messages", icon_url = self.bot.user.avatar_url) + embed.set_author(name = " | Deleted Messages", icon_url = self.bot.user.avatar_url) - embed.set_footer(text = f" | Requested by {ctx.author}.", icon_url = ctx.author.avatar_url) + embed.set_footer(text = f" | Requested by {ctx.author}.", icon_url = ctx.author.avatar_url) - return await ctx.send(embed = embed) + return await ctx.send(embed = embed) # Link to bot def setup(bot): - bot.add_cog(Deleted(bot)) + bot.add_cog(Deleted(bot)) diff --git a/commands/misc/help.py b/commands/misc/help.py index 2b365a1..9c5b073 100644 --- a/commands/misc/help.py +++ b/commands/misc/help.py @@ -1,21 +1,14 @@ -# Prism Rewrite - Basic Command - # Modules -import os -import json - import discord import inspect import importlib -from assets.prism import Tools +from json import loads -from discord.ext import commands +from os import listdir -# Variables -nsfw_commands = [ - "dictionary", "gay", "lesbian", "pp", "slap" -] +from assets.prism import Tools +from discord.ext import commands # Main Command Class class Help(commands.Cog): @@ -27,27 +20,13 @@ def __init__(self, bot): def get_commands(self, ctx, category): - db = json.loads(open("db/guilds", "r").read()) - commands = "" - for command in os.listdir(f"commands/{category}"): + for command in listdir(f"commands/{category}"): if command != "__pycache__": - if not "nsfw-enabled" in db[str(ctx.guild.id)]["tags"]: - - if command[:-3] in nsfw_commands: - - pass - - else: - - commands = f"{commands}, {command[:-3]}" - - else: - - commands = f"{commands}, {command[:-3]}" + commands = f"{commands}, {command[:-3]}" return f"``{commands[2:]}``" @@ -112,7 +91,7 @@ async def embed(self, ctx, cat, prefix, commandClass = None): @commands.command(aliases = ["info", "commands", "cmds"]) async def help(self, ctx, *, category = None): - db = json.loads(open("db/guilds", "r").read()) + db = loads(open("db/guilds", "r").read()) prefix = db[str(ctx.guild.id)]["prefix"] diff --git a/commands/misc/invite.py b/commands/misc/invite.py index 4ad65a5..6089f92 100644 --- a/commands/misc/invite.py +++ b/commands/misc/invite.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from discord.ext import commands diff --git a/commands/misc/leaderboard.py b/commands/misc/leaderboard.py index b445262..7795c2a 100644 --- a/commands/misc/leaderboard.py +++ b/commands/misc/leaderboard.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from json import loads diff --git a/commands/misc/math.py b/commands/misc/math.py index 793be46..e80ef36 100644 --- a/commands/misc/math.py +++ b/commands/misc/math.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import ast import discord diff --git a/commands/misc/pet.py b/commands/misc/pet.py index 2a56530..5a438f2 100644 --- a/commands/misc/pet.py +++ b/commands/misc/pet.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from json import loads @@ -20,17 +18,7 @@ async def pet(self, ctx, user = None): db = loads(open("db/users", "r").read()) - if not user: - - user = ctx.author - - else: - - user = Tools.getClosestUser(ctx, user) - - if not user: - - return await ctx.send(embed = Tools.error(f"I couldn't find that user; try again with more letters.")) + user = await Tools.getClosestUser(ctx, user if user else ctx.author) if not str(user.id) in db: diff --git a/commands/misc/ping.py b/commands/misc/ping.py index 42aaea9..2a06e51 100644 --- a/commands/misc/ping.py +++ b/commands/misc/ping.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from datetime import datetime diff --git a/commands/misc/profile.py b/commands/misc/profile.py index 494d0dd..683513d 100644 --- a/commands/misc/profile.py +++ b/commands/misc/profile.py @@ -1,8 +1,8 @@ # Prism Rewrite - Basic Command # Modules -import json import discord +from json import loads from assets.prism import Tools from discord.ext import commands @@ -16,17 +16,15 @@ def __init__(self, bot): self.usage = "profile [user]" @commands.command(aliases = ["account"]) - async def profile(self, ctx, user: discord.User = None): + async def profile(self, ctx, user = None): - db = json.loads(open("db/users", "r").read()) + db = loads(open("db/users", "r").read()) - if not user: - - user = ctx.author + user = Tools.getClosestUser(ctx, user if user else ctx.author) - elif not str(user.id) in db: + if not str(user.id) in db: - return await ctx.send(f"{user.name} doesn't have an account.") + return await ctx.send(embed = Tools.error(f"{user.name} does not have a Prism account.")) data = db[str(user.id)] diff --git a/commands/misc/question.py b/commands/misc/question.py index c400875..9bfa237 100644 --- a/commands/misc/question.py +++ b/commands/misc/question.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord import wolframalpha diff --git a/commands/misc/server.py b/commands/misc/server.py index d16ef7e..ce337b9 100644 --- a/commands/misc/server.py +++ b/commands/misc/server.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from assets.prism import Tools diff --git a/commands/misc/settings.py b/commands/misc/settings.py index 5e010e9..289fb47 100644 --- a/commands/misc/settings.py +++ b/commands/misc/settings.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from datetime import date @@ -28,19 +26,11 @@ async def settings(self, ctx, key: str = None, value = None): if not key: - nsfw, levels, joinleave, prefix = False, False, "Not Set", _db["prefix"] - - if "nsfw-enabled" in _db["tags"]: - - nsfw = True - - if "levels-enabled" in _db["tags"]: - - levels = True - - if _db["data"]["joinleave_channel"]: + prefix = _db["prefix"] + nsfw = True if "nsfw-enabled" in _db["tags"] else False + levels = True if "levels-enabled" in _db["tags"] else False - joinleave = self.bot.get_channel(_db["data"]["joinleave_channel"]).name + joinleave = self.bot.get_channel(_db["data"]["joinleave_channel"]).name if _db["data"]["joinleave_channel"] else "Not setup" if _db["data"]["autorole"]: diff --git a/commands/misc/shorten.py b/commands/misc/shorten.py index c85bf2a..e80fb1a 100644 --- a/commands/misc/shorten.py +++ b/commands/misc/shorten.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from json import loads diff --git a/commands/misc/stats.py b/commands/misc/stats.py index 44bad77..789f9e1 100644 --- a/commands/misc/stats.py +++ b/commands/misc/stats.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import os import sys @@ -13,7 +11,7 @@ from datetime import datetime from discord.ext import commands -# Variables +# Constants uptime_start = datetime.now() # Main Command Class diff --git a/commands/misc/uptime.py b/commands/misc/uptime.py index bf95923..589dcd1 100644 --- a/commands/misc/uptime.py +++ b/commands/misc/uptime.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import time import discord diff --git a/commands/misc/user.py b/commands/misc/user.py index 40698f9..1f55f86 100644 --- a/commands/misc/user.py +++ b/commands/misc/user.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from assets.prism import Tools @@ -11,23 +9,13 @@ class UserInformation(commands.Cog): def __init__(self, bot): self.bot = bot - self.desc = "Gets a bunch of information on a specific user" + self.desc = "Fetches a user's discord information" self.usage = "user" @commands.command(aliases = ["ui", "userinformation"]) - async def user(self, ctx, user: str = None): - - if not user: - - user = ctx.author - - else: - - user = Tools.getClosestUser(ctx, user, True) - - if not user: + async def user(self, ctx, user = None): - return await ctx.send(embed = Tools.error(f"I couldn't find that user; try again with more letters.")) + user = await Tools.getClosestUser(ctx, user if user else ctx.author, True) def getStatus(status): diff --git a/commands/misc/vote.py b/commands/misc/vote.py index 03fda31..7d6cce7 100644 --- a/commands/misc/vote.py +++ b/commands/misc/vote.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import json import discord diff --git a/commands/moderation/ban.py b/commands/moderation/ban.py index 2a8b89a..60dd094 100644 --- a/commands/moderation/ban.py +++ b/commands/moderation/ban.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from assets.prism import Tools diff --git a/commands/moderation/clearwarnings.py b/commands/moderation/clearwarnings.py index 50c400b..19d2427 100644 --- a/commands/moderation/clearwarnings.py +++ b/commands/moderation/clearwarnings.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from json import loads, dumps diff --git a/commands/moderation/kick.py b/commands/moderation/kick.py index 2beadd7..57f72a8 100644 --- a/commands/moderation/kick.py +++ b/commands/moderation/kick.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from assets.prism import Tools diff --git a/commands/moderation/makerole.py b/commands/moderation/makerole.py index f222dbe..d76ae9a 100644 --- a/commands/moderation/makerole.py +++ b/commands/moderation/makerole.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import random import discord diff --git a/commands/moderation/mute.py b/commands/moderation/mute.py index 229311d..acfa207 100644 --- a/commands/moderation/mute.py +++ b/commands/moderation/mute.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from assets.prism import Tools diff --git a/commands/moderation/purge.py b/commands/moderation/purge.py index 8ed976a..e3bfabe 100644 --- a/commands/moderation/purge.py +++ b/commands/moderation/purge.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from asyncio import sleep diff --git a/commands/moderation/randomban.py b/commands/moderation/randomban.py index e936ab8..4923756 100644 --- a/commands/moderation/randomban.py +++ b/commands/moderation/randomban.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import random import discord diff --git a/commands/moderation/randomkick.py b/commands/moderation/randomkick.py index cd57580..57d88a7 100644 --- a/commands/moderation/randomkick.py +++ b/commands/moderation/randomkick.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import random import discord diff --git a/commands/moderation/tempban.py b/commands/moderation/tempban.py index 9e61e69..4bd4f9a 100644 --- a/commands/moderation/tempban.py +++ b/commands/moderation/tempban.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from asyncio import sleep diff --git a/commands/moderation/unmute.py b/commands/moderation/unmute.py index d186d05..ecdfc72 100644 --- a/commands/moderation/unmute.py +++ b/commands/moderation/unmute.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from assets.prism import Tools diff --git a/commands/moderation/warn.py b/commands/moderation/warn.py index 1d7eddb..198dc3b 100644 --- a/commands/moderation/warn.py +++ b/commands/moderation/warn.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from json import loads, dumps diff --git a/commands/moderation/warnings.py b/commands/moderation/warnings.py index 4e95326..d9d48a1 100644 --- a/commands/moderation/warnings.py +++ b/commands/moderation/warnings.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from json import loads, dumps diff --git a/commands/pets/adopt.py b/commands/pets/adopt.py index 7cd3d7d..15a83be 100644 --- a/commands/pets/adopt.py +++ b/commands/pets/adopt.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from datetime import date diff --git a/commands/pets/fight.py b/commands/pets/fight.py index 20c002c..aaf66f7 100644 --- a/commands/pets/fight.py +++ b/commands/pets/fight.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import json import random diff --git a/commands/pets/hold.py b/commands/pets/hold.py index 9ed7396..f50f280 100644 --- a/commands/pets/hold.py +++ b/commands/pets/hold.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from json import loads, dumps diff --git a/commands/pets/name.py b/commands/pets/name.py index d0c33b1..0e10e51 100644 --- a/commands/pets/name.py +++ b/commands/pets/name.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from json import loads, dumps diff --git a/commands/pets/shelter.py b/commands/pets/shelter.py index db311a5..456af83 100644 --- a/commands/pets/shelter.py +++ b/commands/pets/shelter.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from json import loads, dumps diff --git a/commands/pets/takeback.py b/commands/pets/takeback.py index 0ecfc01..a0dd330 100644 --- a/commands/pets/takeback.py +++ b/commands/pets/takeback.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord from json import loads, dumps diff --git a/commands/pets/train.py b/commands/pets/train.py index e4abb27..60fd804 100644 --- a/commands/pets/train.py +++ b/commands/pets/train.py @@ -1,5 +1,3 @@ -# Prism Rewrite - Basic Command - # Modules import discord