imagine / app.py
artintel235's picture
Update app.py
99fc7a2 verified
raw
history blame
974 Bytes
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)
@tree.command(name="hello", description="Says hello!")
async def hello_command(interaction):
print("Hello command triggered")
await interaction.response.send_message("Hello there! I am functional")
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())