Convert wolfram to a slash command

This commit is contained in:
Luke Robles 2022-10-18 15:28:05 -07:00
parent d63ee287c3
commit 5321de9231
5 changed files with 20 additions and 39 deletions

View File

@ -59,11 +59,19 @@ class ActualUtils(commands.Cog):
await ctx.message.delete() await ctx.message.delete()
os.remove(file_path) os.remove(file_path)
@commands.command(name="ask", aliases=["wolfram"]) @commands.slash_command(
async def ask(self, ctx: commands.Context, *, query): guild_ids=None, name="wolfram", description="Send a query to wolfram alpha"
)
@option(
name="query",
required=True,
description="The query you want to pass to wolfram alpha",
)
async def ask(self, ctx, query):
import questions import questions
await ctx.reply( await ctx.defer()
await ctx.send_followup(
questions.answer_question(query), questions.answer_question(query),
) )

View File

@ -66,28 +66,6 @@ class ServerUtils(commands.Cog):
os.remove(emoji_staging) os.remove(emoji_staging)
return return
@commands.command()
@commands.has_permissions(administrator=True)
async def timeout(
self,
ctx: commands.Context,
member: discord.Member = None,
time=None,
*,
reason=None,
):
import humanfriendly
import datetime
time = humanfriendly.parse_timespan(time)
await member.timeout(
until=discord.utils.utcnow() + datetime.timedelta(seconds=time)
)
await member.send(
"You have been timed out for %s seconds for %s" % (time, reason)
)
await ctx.send("Timed %s out for %s seconds" % (member.mention, time))
@commands.command(name="oncall") @commands.command(name="oncall")
async def oncall(self, ctx: commands.Context): async def oncall(self, ctx: commands.Context):

View File

@ -15,9 +15,9 @@ def get_help_message(method):
"Ask dale bot a question and it will give you an 8ball response", "Ask dale bot a question and it will give you an 8ball response",
"\nUsage: !8ball Will I win the lottery tomorrow?", "\nUsage: !8ball Will I win the lottery tomorrow?",
], ],
"ask": [ "wolfram": [
"Submits your query to wolfram alpha. If that cannot be answered, tries wikipedia\n", "Submits your query to wolfram alpha.\n",
"\nUsage: !ask 100lbs to KG", "\nUsage: !wolfram 100lbs to KG",
], ],
"avatar": [ "avatar": [
"Returns the avatar for the mentioned user", "Returns the avatar for the mentioned user",
@ -262,7 +262,6 @@ def get_help_embed(bot):
], ],
"Utilities": [ "Utilities": [
"8ball", "8ball",
"ask",
"corona", "corona",
"decide", "decide",
"emoji", "emoji",
@ -277,6 +276,7 @@ def get_help_embed(bot):
"tts", "tts",
"vc", "vc",
"wallpaper", "wallpaper",
"wolfram",
"youtube", "youtube",
], ],
"user tools": ["help", "invite", "purge", "roles", "donate"], "user tools": ["help", "invite", "purge", "roles", "donate"],

View File

@ -1,5 +1,4 @@
import os import os
import wikipedia
import wolframalpha import wolframalpha
import help_methods import help_methods
@ -18,10 +17,7 @@ def answer_question(message):
res = client.query(message) res = client.query(message)
return next(res.results).text return next(res.results).text
except Exception: except Exception:
try: return "Sorry, I'm unable to answer that"
return wikipedia.summary(message, sentences=5)
except Exception:
return "Sorry, I'm unable to answer that"
return help_methods.get_help_message("message") return help_methods.get_help_message("message")

View File

@ -1,13 +1,12 @@
beautifulsoup4 beautifulsoup4
cmagick cmagick
git+https://github.com/pycord-development/pycord@40d98dd7acff7ab97ec37cbc74603597975fb5f1
gTTS gTTS
httpx
humanfriendly humanfriendly
lxml lxml
openai
owotext owotext
pandas pandas
git+https://github.com/pycord-development/pycord@40d98dd7acff7ab97ec37cbc74603597975fb5f1
requests requests
wikipedia wolframalpha
wolframalpha
openai
httpx