Files
bot-discord/bot/client.py
2022-04-26 20:15:38 +02:00

17 lines
733 B
Python

import discord
from discord import app_commands
guild_id = '283156308465811456'
class client(discord.Client):
def __init__(self, intents=discord.Intents.default()):
super().__init__(intents=intents)
self.synced = False #we use this so the bot doesn't sync commands more than once
self.tree = tree = app_commands.CommandTree(self)
async def on_ready(self):
await self.wait_until_ready()
if not self.synced: #check if slash commands have been synced
await self.tree.sync(guild = discord.Object(id=guild_id)) #guild specific: leave blank if global (global registration can take 1-24 hours)
self.synced = True
print(f"We have logged in as {self.user}.")