-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
38 lines (24 loc) · 763 Bytes
/
bot.py
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 os
import discord
from discord.ext import commands
from dotenv import load_dotenv
load_dotenv()
intents = discord.Intents.default()
intents.messages = True
intents.guilds = True
intents.message_content = True
bot = commands.Bot(command_prefix='(', intents=intents)
@bot.event
async def on_ready():
print(f'Logged in as {bot.user.name} (ID: {bot.user.id})')
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
await ctx.send('Sorry, I am unable to understand.')
else:
await ctx.send('Internal Error')
@bot.command()
async def hello(ctx):
user_display_name = ctx.author.display_name
await ctx.send(f'Hi {user_display_name}')
bot.run(os.getenv('DISCORD_TOKEN'))