fixups
This commit is contained in:
parent
48d3ac0be2
commit
131f9aa493
2 changed files with 44 additions and 13 deletions
21
bot.py
21
bot.py
|
@ -23,7 +23,8 @@ extensions = (
|
|||
"cogs.playertrack",
|
||||
"cogs.core",
|
||||
"cogs.misc",
|
||||
"cogs.pokemap"
|
||||
"cogs.pokemap",
|
||||
"cogs.games"
|
||||
)
|
||||
|
||||
|
||||
|
@ -60,6 +61,7 @@ class Lina(commands.Bot):
|
|||
self.stk_userid: int = None
|
||||
self.stk_token: str = None
|
||||
self.stk_sessid: str = None
|
||||
self.version = "1.1.2"
|
||||
|
||||
async def stkPostReq(self, target, args):
|
||||
"""Helper function to send a POST request to STK servers."""
|
||||
|
@ -159,6 +161,9 @@ class Lina(commands.Bot):
|
|||
if isinstance(error, commands.NoPrivateMessage):
|
||||
return await ctx.author.send("You can't use this command in private messages.")
|
||||
|
||||
if isinstance(error, commands.NotOwner):
|
||||
return await ctx.send("This command is restricted to the owner only.")
|
||||
|
||||
if isinstance(error, commands.CommandInvokeError):
|
||||
error: commands.CommandInvokeError
|
||||
original = error.original
|
||||
|
@ -170,15 +175,15 @@ class Lina(commands.Bot):
|
|||
color=self.accent_color
|
||||
))
|
||||
|
||||
return await ctx.send(embed=discord.Embed(
|
||||
title="Sorry, this shouldn't have happened. Guru Meditation.",
|
||||
description=f"```\n{error.original.__class__.__name__}: {str(error.original)}\n```",
|
||||
color=self.accent_color
|
||||
))
|
||||
return await ctx.send(embed=discord.Embed(
|
||||
title="Sorry, this shouldn't have happened. Guru Meditation.",
|
||||
description=f"```\n{error.original.__class__.__name__}: {str(error.original)}\n```",
|
||||
color=self.accent_color
|
||||
))
|
||||
|
||||
async def on_app_command_error(self, interaction: discord.Interaction, error: app_commands.AppCommandError):
|
||||
log.exception("%s: App command error occurred.", interaction.command.name, exc_info=error)
|
||||
|
||||
|
||||
if isinstance(error, app_commands.CommandInvokeError):
|
||||
error: app_commands.CommandInvokeError
|
||||
original = error.original
|
||||
|
@ -216,7 +221,7 @@ class Lina(commands.Bot):
|
|||
self.session = ClientSession(
|
||||
"https://online.supertuxkart.net",
|
||||
headers={
|
||||
"User-Agent": "DiscordBot (linaSTK 1.0)"
|
||||
"User-Agent": f"linaSTK-Discord/{self.version} (+https://codeberg.org/kita/lina-discord)"
|
||||
}
|
||||
)
|
||||
|
||||
|
|
36
cogs/core.py
36
cogs/core.py
|
@ -3,6 +3,9 @@ from __future__ import annotations
|
|||
import discord
|
||||
from discord.ext import commands
|
||||
import logging
|
||||
from sys import version as python_version
|
||||
from aiohttp import __version__ as aiohttp_version
|
||||
from asyncpg import __version__ as asyncpg_version
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
log = logging.getLogger("lina.cogs.core")
|
||||
|
@ -15,10 +18,7 @@ class Core(commands.Cog):
|
|||
def __init__(self, bot: Lina):
|
||||
self.bot: Lina = bot
|
||||
|
||||
async def cog_check(self, ctx: commands.Context) -> bool:
|
||||
|
||||
return await self.bot.is_owner(ctx.author)
|
||||
|
||||
@commands.is_owner()
|
||||
@commands.command(hidden=True)
|
||||
async def load(self, ctx: commands.Context, *, mod: str):
|
||||
try:
|
||||
|
@ -30,7 +30,7 @@ class Core(commands.Cog):
|
|||
else:
|
||||
await ctx.reply("Loaded.")
|
||||
|
||||
|
||||
@commands.is_owner()
|
||||
@commands.command(hidden=True)
|
||||
async def unload(self, ctx: commands.Context, *, mod: str):
|
||||
try:
|
||||
|
@ -42,6 +42,7 @@ class Core(commands.Cog):
|
|||
else:
|
||||
await ctx.reply("Unloaded.")
|
||||
|
||||
@commands.is_owner()
|
||||
@commands.command(hidden=True)
|
||||
async def reload(self, ctx: commands.Context, *, mod: str):
|
||||
try:
|
||||
|
@ -78,10 +79,35 @@ class Core(commands.Cog):
|
|||
commands = await self.bot.tree.sync()
|
||||
await ctx.reply(f"Successfully synced {len(commands)} commands.")
|
||||
|
||||
@commands.is_owner()
|
||||
@commands.command(hidden=True)
|
||||
async def shutdown(self, ctx: commands.Context):
|
||||
await ctx.reply("Shutting down :wave:")
|
||||
await self.bot.close()
|
||||
|
||||
@commands.hybrid_command(name="version")
|
||||
async def version(self, ctx: commands.Context):
|
||||
await ctx.reply(embed=discord.Embed(
|
||||
title="Version information",
|
||||
description=(
|
||||
"## Core\n"
|
||||
"**linaSTK**: {version}\n"
|
||||
"**Python**: {pythonversion}\n"
|
||||
"**discord.py**: {discordpyversion}\n"
|
||||
"**AIOHTTP**: {aiohttpversion}\n"
|
||||
"**asyncpg**: {asyncpgversion}\n\n"
|
||||
"## Kernel Version\n"
|
||||
"```\n{kernelver}\n```").format(
|
||||
version=self.bot.version,
|
||||
discordpyversion=discord.__version__,
|
||||
pythonversion=python_version,
|
||||
kernelver=open("/proc/version").read(),
|
||||
aiohttpversion=aiohttp_version,
|
||||
asyncpgversion=asyncpg_version
|
||||
),
|
||||
color=self.bot.accent_color
|
||||
).set_thumbnail(url=self.bot.user.avatar.url),
|
||||
mention_author=False)
|
||||
|
||||
async def setup(bot: Lina):
|
||||
await bot.add_cog(Core(bot))
|
||||
|
|
Loading…
Reference in a new issue