Added a shutdown command
This commit is contained in:
@ -6,6 +6,7 @@ import os
|
||||
|
||||
load_dotenv()
|
||||
GUILD_ID = int(os.getenv("DISCORD_GUILD_ID"))
|
||||
OWNER_ID = int(os.getenv("AUTHORIZED_USER_ID")) # Ensure your .env has your Discord user ID
|
||||
|
||||
class Dolly(discord.Client):
|
||||
|
||||
@ -16,7 +17,19 @@ class Dolly(discord.Client):
|
||||
async def setup_hook(self):
|
||||
self.tree.add_command(DollyTracker())
|
||||
self.tree.copy_global_to(guild = discord.Object(id=GUILD_ID))
|
||||
await self.tree.sync(guild = discord.Object(id=GUILD_ID))
|
||||
|
||||
await self.tree.sync(guild=discord.Object(id=GUILD_ID))
|
||||
|
||||
# Adding a guild-specific shutdown command
|
||||
@self.tree.command(name="shutdown", description="Shut down the bot", guild_ids=[GUILD_ID])
|
||||
async def shutdown(interaction: discord.Interaction):
|
||||
if interaction.user.id == OWNER_ID:
|
||||
await interaction.response.send_message("Shutting down...")
|
||||
await self.close()
|
||||
else:
|
||||
await interaction.response.send_message("You do not have permission to use this command.", ephemeral=True)
|
||||
|
||||
async def on_ready(self):
|
||||
print(f"Logged on as {self.user}!")
|
||||
print(f"Logged on as {self.user}!")
|
||||
# Ensuring commands are only available in specified guild
|
||||
self.tree.copy_global_to(guild=discord.Object(id=GUILD_ID))
|
||||
await self.tree.sync(guild=discord.Object(id=GUILD_ID))
|
||||
|
Reference in New Issue
Block a user