define example bot
This commit is contained in:
parent
728c368db0
commit
593877441f
1 changed files with 23 additions and 0 deletions
23
src/discordbot/app.py
Normal file
23
src/discordbot/app.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
import os
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
# Read env variables
|
||||
bot_token = os.environ.get('DISCORDBOT_TOKEN', 'token')
|
||||
scheduler_hostname = os.environ.get('SCHEDULER_API_HOSTNAME', 'tv.example.com')
|
||||
|
||||
# Create a bot instance with a command prefix
|
||||
bot = commands.Bot(command_prefix='!')
|
||||
|
||||
# Define a simple command
|
||||
@bot.command(name='about', help='Displays about info')
|
||||
async def hello(ctx):
|
||||
await ctx.send(f'Hello {ctx.author.name}! ')
|
||||
|
||||
# Define an event when the bot is ready
|
||||
@bot.event
|
||||
async def on_ready():
|
||||
print(f'Logged in as {bot.user.name}')
|
||||
|
||||
# Run the bot with your bot token
|
||||
bot.run(bot_token)
|
Loading…
Reference in a new issue