-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
32 lines (25 loc) · 763 Bytes
/
bot.py
File metadata and controls
32 lines (25 loc) · 763 Bytes
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
# bot.py
# Import necessary libraries
import discord
import markdown
from discord.ext import commands
from dotenv import load_dotenv
import os
# Import the ask_question function from explore.py
from explore import ask_question
# Load environment variables from .env file
load_dotenv()
# Get the Discord token
DISCORD_TOKEN = os.getenv('DISCORD_TOKEN')
# Initialize the bot with all intents
intents = discord.Intents.all()
bot = commands.Bot(command_prefix='!', intents=intents)
# Define a command called 'ask'
@bot.command()
async def ask(ctx, *, question):
# Call the ask_question function from explore.py
answer = ask_question(question)
# Send the answer to the Discord channel
await ctx.send(answer)
# Run the bot
bot.run(DISCORD_TOKEN)