mirror of
https://github.com/nexy7574/LCC-bot.git
synced 2024-09-20 02:26:32 +01:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
f2d5a0583c
2 changed files with 27 additions and 2 deletions
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
"python.linting.pycodestyleEnabled": true,
|
"python.linting.pycodestyleEnabled": false,
|
||||||
"python.linting.enabled": false
|
"python.linting.enabled": false,
|
||||||
|
"python.analysis.typeCheckingMode": "basic"
|
||||||
}
|
}
|
|
@ -955,6 +955,30 @@ class OtherCog(commands.Cog):
|
||||||
|
|
||||||
await ctx.send_modal(TextModal())
|
await ctx.send_modal(TextModal())
|
||||||
|
|
||||||
|
@commands.slash_command()
|
||||||
|
@commands.cooldown(5, 10, commands.BucketType.user)
|
||||||
|
@commands.max_concurrency(1, commands.BucketType.user)
|
||||||
|
async def quote(self, ctx: discord.ApplicationContext):
|
||||||
|
"""Generates a random quote"""
|
||||||
|
await ctx.defer()
|
||||||
|
try:
|
||||||
|
response = await self.http.get("https://inspirobot.me/api?generate=true")
|
||||||
|
except (ConnectionError, httpx.HTTPError, httpx.NetworkError) as e:
|
||||||
|
return await ctx.respond("Failed to get quote. " + str(e))
|
||||||
|
if response.status_code != 200:
|
||||||
|
return await ctx.respond(f"Failed to get quote. Status code: {response.status_code}")
|
||||||
|
url = response.text
|
||||||
|
try:
|
||||||
|
response = await self.http.get(url)
|
||||||
|
except (ConnectionError, httpx.HTTPError, httpx.NetworkError) as e:
|
||||||
|
return await ctx.respond(url)
|
||||||
|
else:
|
||||||
|
if response.status_code != 200:
|
||||||
|
return await ctx.respond(url)
|
||||||
|
x = io.BytesIO(response.content)
|
||||||
|
x.seek(0)
|
||||||
|
await ctx.respond(file=discord.File(x, filename="quote.jpg"))
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(OtherCog(bot))
|
bot.add_cog(OtherCog(bot))
|
||||||
|
|
Loading…
Reference in a new issue