File size: 974 Bytes
700b1d7
 
c01a950
c139e5d
7678033
700b1d7
c139e5d
 
700b1d7
 
 
c01a950
700b1d7
 
49500f7
99fc7a2
700b1d7
dda26c7
49500f7
c139e5d
700b1d7
 
c139e5d
700b1d7
c84fec8
49500f7
c84fec8
49500f7
c84fec8
7678033
 
 
 
 
c01a950
c139e5d
49500f7
c84fec8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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())