From 3c18d552c2c9eb15834b33687915a7b16c98883b Mon Sep 17 00:00:00 2001 From: Parker Date: Sat, 25 Jan 2025 22:58:41 -0600 Subject: reupload --- code/cogs/tree_sync.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 code/cogs/tree_sync.py (limited to 'code/cogs/tree_sync.py') diff --git a/code/cogs/tree_sync.py b/code/cogs/tree_sync.py new file mode 100644 index 0000000..d3f8307 --- /dev/null +++ b/code/cogs/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)) \ No newline at end of file -- cgit v1.2.3-70-g09d2