2024-01-14 21:45:31 -05:00
|
|
|
import os
|
|
|
|
import discord
|
|
|
|
|
|
|
|
# Read env variables
|
|
|
|
bot_token = os.environ.get('DISCORDBOT_TOKEN', 'token')
|
|
|
|
scheduler_hostname = os.environ.get('SCHEDULER_API_HOSTNAME', 'tv.example.com')
|
|
|
|
|
2024-01-14 22:07:15 -05:00
|
|
|
# Intents
|
|
|
|
intents = discord.Intents.default()
|
|
|
|
intents.message_content = True
|
2024-01-14 21:45:31 -05:00
|
|
|
|
2024-01-14 22:07:15 -05:00
|
|
|
client = discord.Client(intents=intents)
|
2024-01-14 21:45:31 -05:00
|
|
|
|
|
|
|
# Define an event when the bot is ready
|
2024-01-14 22:07:15 -05:00
|
|
|
@client.event
|
2024-01-14 21:45:31 -05:00
|
|
|
async def on_ready():
|
2024-01-14 22:07:15 -05:00
|
|
|
print(f'Logged in as {client.user}')
|
2024-01-14 21:45:31 -05:00
|
|
|
|
2024-01-14 22:07:15 -05:00
|
|
|
@client.event
|
|
|
|
async def on_message(message):
|
|
|
|
if message.author == client.user:
|
|
|
|
return
|
|
|
|
|
|
|
|
if message.content.startswith('!hello'):
|
|
|
|
await message.channel.send('Hello!')
|
|
|
|
|
|
|
|
client.run(bot_token)
|