aboutsummaryrefslogtreecommitdiff
path: root/code/cogs/owner/sync.py
diff options
context:
space:
mode:
authorParker <contact@pkrm.dev>2024-10-31 05:26:36 +0000
committerGitHub <noreply@github.com>2024-10-31 05:26:36 +0000
commit5be16a998857d1f14410904a41d052070d5f8776 (patch)
tree6b26a4dc377ccf209c37eabf673d6031fdc10987 /code/cogs/owner/sync.py
parentc1b229f34c010108b0e7eb92de2102dfc07ae70c (diff)
parent70e612882d1093b133d13302dccfba6aa2778474 (diff)
Merge pull request #9 from PacketParker/dev
`black --line-length 79`
Diffstat (limited to 'code/cogs/owner/sync.py')
-rw-r--r--code/cogs/owner/sync.py50
1 files changed, 39 insertions, 11 deletions
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):