reqrite in discord.py v2
This commit is contained in:
1
bot/__init__.py
Normal file
1
bot/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .client import client
|
||||
17
bot/client.py
Normal file
17
bot/client.py
Normal file
@@ -0,0 +1,17 @@
|
||||
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}.")
|
||||
Reference in New Issue
Block a user