aboutsummaryrefslogtreecommitdiff
path: root/code/cogs/tree_sync.py
diff options
context:
space:
mode:
authorParker <contact@pkrm.dev>2024-05-18 20:06:51 -0500
committerParker <contact@pkrm.dev>2024-05-18 20:06:51 -0500
commit32ab780b461c1c2b5e3e34c35b5902ed7006b95e (patch)
treeb8717f5d5136b36c3d9bfe9e00346a7747003596 /code/cogs/tree_sync.py
parentf0ec1c5a896744e4cdaa377a50b6277562a29f7f (diff)
Create CordArr
Diffstat (limited to 'code/cogs/tree_sync.py')
-rw-r--r--code/cogs/tree_sync.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/code/cogs/tree_sync.py b/code/cogs/tree_sync.py
new file mode 100644
index 0000000..5050730
--- /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))