48 lines
1.4 KiB
Python
48 lines
1.4 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)")
|
|
intents = discord.Intents.default()
|
|
intents.message_content = True
|
|
super().__init__(intents=intents, command_prefix="!", activity=activity, help_command=commands.DefaultHelpCommand())
|
|
|
|
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())
|