weeabot/slash_commands.py
2022-12-15 20:36:19 +11:00

45 lines
1.3 KiB
Python

import discord
from discord import app_commands
from discord.ext import commands
import os
import asyncio
try:
with open("token.secret", 'r') as f:
discord_client_token = f.read()
except FileNotFoundError:
print("Cannot locate token.secret please generate a token")
exit(69)
class aclient(commands.Bot):
def __init__(self):
activity = discord.Activity(type=discord.ActivityType.listening, name="Waiting for your prompt :3 (Main API)")
super().__init__(intents=discord.Intents.default(), command_prefix="!", activity=activity)
self.synced = False
async def load(self):
for filename in os.listdir("./commands"):
if filename.endswith(".py"):
print(f"Loading commands.{filename[:-3]}")
await self.load_extension(f"commands.{filename[:-3]}")
async def on_ready(self):
await self.wait_until_ready()
if not self.synced:
await tree.sync(guild=discord.Object(id=775297479783874570))
self.synced = True
print(f"We have logged in as {self.user}.")
pass
client = aclient()
tree = client.tree
async def main():
await client.load()
await client.start(discord_client_token)
# client.run(discord_client_token)
asyncio.run(main())