Hi,
I have a question
I'm having trouble understanding the slash command synchronization stuff. I usually create bots for my own guilds, so it hasn't been an issue, and the slash commands work perfectly.
But now I'm making a bot that isn't just for my guild. It's running on a VPS (Virtual Private Server) all the time. So, if someone invites the bot to their Discord server while it's running, how can I ensure that the slash commands also work on their Discord server without me needing to restart the Python script?
class MyBot(commands.Bot):
def __init__(self):
super().__init__(
command_prefix=praefix,
intents=discord.Intents.all(),
application_id=Application_ID,
activity=discord.Game(activity_text)
)
self.initial_extensions = [
"discord_cogs.admin.pre_setup",
# ......
]
async def setup_hook(self):
"""Load initial extensions during bot setup."""
for ext in self.initial_extensions:
await self.load_extension(ext)
await bot.tree.sync(guild=discord.Object(guild_id))
what i want to do is think : trigger an event when someone invites my bot : then exutute pyawait bot.tree.sync(guild=discord.Object(guild_id)) on the specific guild id ???