Spaces:
Sleeping
Sleeping
import discord | |
from discord import app_commands | |
import os | |
import asyncio | |
import time | |
DISCORD_BOT_TOKEN = os.getenv("DISCORD_BOT_TOKEN") | |
intents = discord.Intents.default() | |
client = discord.Client(intents=intents) | |
tree = app_commands.CommandTree(client) | |
async def hello_command(interaction): | |
print("Hello command triggered") | |
await interaction.response.send_message("Hello there! I am running perfectly on huggingface") | |
async def on_ready(): | |
print("on_ready() called") | |
await tree.sync() | |
print("Bot is ready!") | |
client.event(on_ready) | |
async def main(): | |
print("Inside main()") | |
async with client: | |
print("Starting client...") | |
await client.start(DISCORD_BOT_TOKEN) | |
print("Bot has started.") | |
# Keep the main function alive: | |
while True: | |
await asyncio.sleep(60) # Sleep for 60 seconds | |
if __name__ == "__main__": | |
print("Running main()") | |
asyncio.run(main()) |