-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
84 lines (70 loc) · 2.85 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import random
import discord
import json
from discord.ext import commands, tasks
from discord import Embed
from discord.commands import Option
import openai
bot = commands.Bot()
@bot.event
async def on_ready():
status_task.start()
print(f"{bot.user} is ready and online!")
@bot.slash_command(name = "hello", description = "Say hello to the bot")
async def hello(ctx):
await ctx.respond("Hey!")
@bot.slash_command(name = "ask_aubie", description="Ask Aubie Anything!")
async def ask_aubie(ctx, message: Option(str)):
embed = Embed(title="Ask Aubie")
response = openai.Completion.create(
engine="text-davinci-003",
prompt=message,
max_tokens=600,
n=1,
stop=None,
temperature=0.5
)
embed.add_field(name=message, value=response.choices[0].text.strip())
await ctx.respond(embed=embed)
@bot.slash_command(name = "contribute", description = "Run this command for more information on how to contribute to the bot.")
async def contribute(ctx):
embed = Embed(title="How you can contribute", description="This will provide you with all the info you need to contribute to the bot")
embed.add_field(name="How?", value="Head over to github and read the README. This will explain everything you need to know.", inline=False)
embed.add_field(name="Ideas", value = "If you are looking for ideas to contribute, run the command /todo")
embed.url = "https://github.com/offsetkeyz/au-discord-bot"
await ctx.respond(embed=embed)
@bot.slash_command(name = "todo", description = "Get ideas for contributions")
async def todo(ctx):
embed = Embed(title="Ideas for Contributions")
with open('bot.py') as f:
code = f.read()
todos = []
for line in code.split('\n'):
if "#TODO " in line and not line.strip().startswith('if'):
todos.append(line.strip())
if todos:
i = 1
for todo in todos:
todo_stripped = todo.replace("#TODO","",1)
embed.add_field(name=f"Idea {i}", value=todo_stripped, inline=False)
i=i+1
await ctx.respond(embed=embed)
else:
await ctx.respond("No TODOs, but don't let that stop you!")
@tasks.loop(minutes=1.0)
async def status_task() -> None:
"""
Setup the game status task of the bot
"""
statuses = ["seeking contributors!", "please contribute!"]
await bot.change_presence(activity=discord.Game(random.choice(statuses)))
with open('config.json') as f:
config = json.load(f)
TOKEN = config['token']
openai.api_key = config['openai']
openai.organization = config['organization']
bot.run(TOKEN)
#TODO Create an RSS reader for different feeds in CS
#TODO Command that shows advisors and their contact information.
#TODO Scrape data from Auburn's Website and feed it to a channel
#TODO Ask ChatGPT Bot