From 5cda1829241e706ecc16e814e450fc492022151a Mon Sep 17 00:00:00 2001 From: Parker Date: Wed, 3 Apr 2024 15:41:28 -0500 Subject: Move `tree_sync.py` into `owner` folder --- code/cogs/owner/tree_sync.py | 33 +++++++++++++++++++++++++++++++++ code/cogs/tree_sync.py | 33 --------------------------------- 2 files changed, 33 insertions(+), 33 deletions(-) create mode 100644 code/cogs/owner/tree_sync.py delete mode 100644 code/cogs/tree_sync.py diff --git a/code/cogs/owner/tree_sync.py b/code/cogs/owner/tree_sync.py new file mode 100644 index 0000000..5050730 --- /dev/null +++ b/code/cogs/owner/tree_sync.py @@ -0,0 +1,33 @@ +from discord.ext import commands +from discord import Object + + +class TreeSync(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.command() + @commands.dm_only() + @commands.is_owner() + async def sync(self, ctx: commands.Context, *, guild: Object = None) -> None: + if not guild or guild == None: + await self.bot.tree.sync() + await ctx.author.send("Synced commands globally") + return + + elif guild != None: + self.bot.tree.copy_global_to(guild=guild) + await self.bot.tree.sync(guild=guild) + + await ctx.author.send(f"Synced the tree to 1 test guild.") + + @sync.error + async def error_sync(self, ctx, error): + if isinstance(error, commands.errors.PrivateMessageOnly): + pass + else: + await ctx.author.send("That is not a valid guild ID") + + +async def setup(bot): + await bot.add_cog(TreeSync(bot)) diff --git a/code/cogs/tree_sync.py b/code/cogs/tree_sync.py deleted file mode 100644 index 5050730..0000000 --- a/code/cogs/tree_sync.py +++ /dev/null @@ -1,33 +0,0 @@ -from discord.ext import commands -from discord import Object - - -class TreeSync(commands.Cog): - def __init__(self, bot): - self.bot = bot - - @commands.command() - @commands.dm_only() - @commands.is_owner() - async def sync(self, ctx: commands.Context, *, guild: Object = None) -> None: - if not guild or guild == None: - await self.bot.tree.sync() - await ctx.author.send("Synced commands globally") - return - - elif guild != None: - self.bot.tree.copy_global_to(guild=guild) - await self.bot.tree.sync(guild=guild) - - await ctx.author.send(f"Synced the tree to 1 test guild.") - - @sync.error - async def error_sync(self, ctx, error): - if isinstance(error, commands.errors.PrivateMessageOnly): - pass - else: - await ctx.author.send("That is not a valid guild ID") - - -async def setup(bot): - await bot.add_cog(TreeSync(bot)) -- cgit v1.2.3-70-g09d2