Files
bot.py
config.json
requirements.txt
Code
3 38
bot.py
import discord
from discord.ext import commands
import os
from dotenv import load_dotenv
import logging
load_dotenv()
logging.basicConfig(level=logging.INFO)
bot = commands.Bot(command_prefix='!', intents=discord.Intents.all())
@bot.event
async def on_ready():
logging.info(f'Bot is ready! Logged in as {bot.user}')
@bot.command()
async def hello(ctx):
embed = discord.Embed(title="Hello!", description=f"Hello {ctx.author.mention}!", color=0x00ff00)
await ctx.send(embed=embed)
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
await ctx.send("Command not found.")
else:
logging.error(f"Error: {error}")
bot.run(os.getenv('DISCORD_TOKEN'))