aboutsummaryrefslogtreecommitdiff
path: root/code/cogs/owner
diff options
context:
space:
mode:
Diffstat (limited to 'code/cogs/owner')
-rw-r--r--code/cogs/owner/cog.py13
-rw-r--r--code/cogs/owner/stats.py21
-rw-r--r--code/cogs/owner/sync.py50
3 files changed, 65 insertions, 19 deletions
diff --git a/code/cogs/owner/cog.py b/code/cogs/owner/cog.py
index 78dc246..a090414 100644
--- a/code/cogs/owner/cog.py
+++ b/code/cogs/owner/cog.py
@@ -9,7 +9,10 @@ class CogCommands(commands.Cog):
@commands.dm_only()
@commands.is_owner()
async def cog(self, ctx):
- await ctx.author.send(f"This is a group command. Use `{self.bot.command_prefix}cog load/unload/reload` followed by the name of the cog.")
+ await ctx.author.send(
+ f"This is a group command. Use `{self.bot.command_prefix}cog"
+ " load/unload/reload` followed by the name of the cog."
+ )
@cog.command()
@commands.dm_only()
@@ -47,7 +50,9 @@ class CogCommands(commands.Cog):
@unload.error
async def cog_unload_error(self, ctx, error):
if isinstance(error.original, commands.ExtensionNotLoaded):
- return await ctx.send("Cog not loaded. It might be that the cog does not exist.")
+ return await ctx.send(
+ "Cog not loaded. It might be that the cog does not exist."
+ )
else:
return await ctx.send("An unknown error occurred.")
@@ -66,7 +71,9 @@ class CogCommands(commands.Cog):
@reload.error
async def cog_reload_error(self, ctx, error):
if isinstance(error.original, commands.ExtensionNotLoaded):
- return await ctx.send("Cog not loaded. It might be that the cog does not exist.")
+ return await ctx.send(
+ "Cog not loaded. It might be that the cog does not exist."
+ )
else:
return await ctx.send("An unknown error occurred.")
diff --git a/code/cogs/owner/stats.py b/code/cogs/owner/stats.py
index 362dc6a..6ab9043 100644
--- a/code/cogs/owner/stats.py
+++ b/code/cogs/owner/stats.py
@@ -17,7 +17,8 @@ class Stats(commands.Cog):
connection = sqlite3.connect("data/count.db")
cursor = connection.cursor()
cursor.execute(
- "CREATE TABLE IF NOT EXISTS count (command_name, count, PRIMARY KEY (command_name))"
+ "CREATE TABLE IF NOT EXISTS count (command_name, count, PRIMARY"
+ " KEY (command_name))"
)
connection.commit()
connection.close()
@@ -37,7 +38,8 @@ class Stats(commands.Cog):
)
except sqlite3.IntegrityError:
cursor.execute(
- "UPDATE count SET count = count + ? WHERE command_name = ?",
+ "UPDATE count SET count = count + ? WHERE"
+ " command_name = ?",
(count, command_name),
)
@@ -65,16 +67,25 @@ class Stats(commands.Cog):
).fetchall()
# Get the combined total amount of commands run
- total_commands = cursor.execute("SELECT SUM(count) FROM count").fetchone()[0]
+ total_commands = cursor.execute(
+ "SELECT SUM(count) FROM count"
+ ).fetchone()[0]
embed = discord.Embed(
title="Statistics",
- description=f"Total Guilds: `{len(self.bot.guilds):,}`\nTotal Commands: `{total_commands:,}`\n\nTotal Players: `{self.bot.lavalink.nodes[0].stats.playing_players}`\nLoad: `{round(self.bot.lavalink.nodes[0].stats.lavalink_load * 100, 2)}%`",
+ description=(
+ f"Total Guilds: `{len(self.bot.guilds):,}`\nTotal Commands:"
+ f" `{total_commands:,}`\n\nTotal Players:"
+ f" `{self.bot.lavalink.nodes[0].stats.playing_players}`\nLoad:"
+ f" `{round(self.bot.lavalink.nodes[0].stats.lavalink_load * 100, 2)}%`"
+ ),
color=BOT_COLOR,
)
for entry in data:
- embed.add_field(name=entry[0], value=f"` {entry[1]:,} `", inline=True)
+ embed.add_field(
+ name=entry[0], value=f"` {entry[1]:,} `", inline=True
+ )
connection.close()
await ctx.send(embed=embed)
diff --git a/code/cogs/owner/sync.py b/code/cogs/owner/sync.py
index 05259cf..d6647b5 100644
--- a/code/cogs/owner/sync.py
+++ b/code/cogs/owner/sync.py
@@ -10,17 +10,27 @@ class TreeSync(commands.Cog):
@commands.dm_only()
@commands.is_owner()
async def tree(self, ctx):
- await ctx.author.send(f"This is a group command. Use either `{self.bot.command_prefix}tree sync` or `{self.bot.command_prefix}tree clear` followed by an optional guild ID.")
+ await ctx.author.send(
+ "This is a group command. Use either"
+ f" `{self.bot.command_prefix}tree sync` or"
+ f" `{self.bot.command_prefix}tree clear` followed by an optional"
+ " guild ID."
+ )
@commands.dm_only()
@commands.is_owner()
@tree.command()
- async def sync(self, ctx: commands.Context, *, guild: discord.Object = None):
+ async def sync(
+ self, ctx: commands.Context, *, guild: discord.Object = None
+ ):
"""Sync the command tree to a guild or globally."""
if guild:
self.bot.tree.copy_global_to(guild=guild)
await self.bot.tree.sync(guild=guild)
- return await ctx.author.send(f"Synced the command tree to `{self.bot.get_guild(guild.id).name}`")
+ return await ctx.author.send(
+ "Synced the command tree to"
+ f" `{self.bot.get_guild(guild.id).name}`"
+ )
else:
await self.bot.tree.sync()
return await ctx.author.send("Synced the command tree globally.")
@@ -28,11 +38,17 @@ class TreeSync(commands.Cog):
@sync.error
async def tree_sync_error(self, ctx, error):
if isinstance(error, commands.ObjectNotFound):
- return await ctx.author.send("The guild you provided does not exist.")
+ return await ctx.author.send(
+ "The guild you provided does not exist."
+ )
if isinstance(error, commands.CommandInvokeError):
- return await ctx.author.send("Guild ID provided is not a guild that the bot is in.")
+ return await ctx.author.send(
+ "Guild ID provided is not a guild that the bot is in."
+ )
else:
- return await ctx.author.send("An unknown error occurred. Perhaps you've been rate limited.")
+ return await ctx.author.send(
+ "An unknown error occurred. Perhaps you've been rate limited."
+ )
@commands.dm_only()
@commands.is_owner()
@@ -41,18 +57,30 @@ class TreeSync(commands.Cog):
"""Clear the command tree from a guild."""
self.bot.tree.clear_commands(guild=guild)
await self.bot.tree.sync(guild=guild)
- return await ctx.author.send(f"Cleared the command tree from `{self.bot.get_guild(guild.id).name}`")
+ return await ctx.author.send(
+ "Cleared the command tree from"
+ f" `{self.bot.get_guild(guild.id).name}`"
+ )
@clear.error
async def tree_sync_error(self, ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
- return await ctx.author.send("You need to provide a guild ID to clear the command tree from.")
+ return await ctx.author.send(
+ "You need to provide a guild ID to clear the command tree"
+ " from."
+ )
if isinstance(error, commands.ObjectNotFound):
- return await ctx.author.send("The guild you provided does not exist.")
+ return await ctx.author.send(
+ "The guild you provided does not exist."
+ )
if isinstance(error, commands.CommandInvokeError):
- return await ctx.author.send("Guild ID provided is not a guild that the bot is in.")
+ return await ctx.author.send(
+ "Guild ID provided is not a guild that the bot is in."
+ )
else:
- return await ctx.author.send("An unknown error occurred. Perhaps you've been rate limited.")
+ return await ctx.author.send(
+ "An unknown error occurred. Perhaps you've been rate limited."
+ )
async def setup(bot):