1
Fork 0
mirror of https://github.com/RGBCube/minearchy-bot synced 2025-07-27 00:47:44 +00:00

Move bot class location and fix some bugs

This commit is contained in:
RGBCube 2022-11-27 12:12:50 +03:00
parent 577b7ce131
commit 66e766d5ff
7 changed files with 122 additions and 117 deletions

View file

@ -3,6 +3,7 @@ from __future__ import annotations
from contextlib import suppress as suppress_error
from traceback import format_exception as format_exit
from typing import TYPE_CHECKING
from asyncio import gather as await_parallel
from discord import HTTPException
from discord.ext.commands import (
@ -19,7 +20,7 @@ from discord.ext.commands import (
if TYPE_CHECKING:
from discord.ext.commands import CommandError, Context
from ..core import MinearchyBot
from .. import MinearchyBot
class ErrorHandler(Cog):
@ -62,7 +63,12 @@ class ErrorHandler(Cog):
else:
trace = "".join(format_exit(type(error), error, error.__traceback__))
print(f"Ignoring exception in command {ctx.command}:\n{trace}")
await self.bot.log_webhook.send(f"<@512640455834337290>```{trace}```")
await await_parallel(
self.bot.log_webhook.send(f"<@512640455834337290>```{trace}```"),
ctx.reply(
"An error occurred while executing the command. The error has been reported."
),
)
async def setup(bot: MinearchyBot) -> None:

View file

@ -8,7 +8,7 @@ from discord.ui import Button, View
if TYPE_CHECKING:
from discord.ext.commands import Context
from ..core import MinearchyBot
from .. import MinearchyBot
class MinecraftServer(

View file

@ -17,7 +17,7 @@ if TYPE_CHECKING:
from discord import Message
from discord.ext.commands import Context
from ..core import MinearchyBot
from .. import MinearchyBot
class Miscellaneous(
@ -72,7 +72,8 @@ class Miscellaneous(
self.sniped[message.channel.id].appendleft((message, int(current_time())))
self.sniped[message.channel.id] = self.sniped[message.channel.id][:5] # type: ignore
while len(self.sniped[message.channel.id]) > 5:
self.sniped[message.channel.id].pop()
@command(
brief="Sends the latest deleted messages.",
@ -82,7 +83,7 @@ class Miscellaneous(
),
)
@has_permissions(manage_messages=True) # needs to be able to delete messages to run the command
async def snipe(self, ctx: Context, channel: TextChannel = None) -> None: # type: ignore
async def snipe(self, ctx: Context, channel: TextChannel = None) -> None:
if channel is None:
channel = ctx.channel
@ -113,13 +114,13 @@ class Miscellaneous(
name=str(i) + ("" if i else " (latest)"),
value=strip_doc(
f"""
Author: {message.author.mention} (ID: {message.author.id}, Plain: {escape_markdown(str(message.author))})
Deleted at: <t:{ts}:F> (Relative: <t:{ts}:R>)
Content:
```
{message.content.replace('`', f'{zwsp}`{zwsp}')}
```
"""
Author: {message.author.mention} (ID: {message.author.id}, Plain: {escape_markdown(str(message.author))})
Deleted at: <t:{ts}:F> (Relative: <t:{ts}:R>)
Content:
```
{message.content.replace('`', f'{zwsp}`{zwsp}')}
```
"""
),
inline=False,
)

View file

@ -7,7 +7,7 @@ from discord import Member
from discord.ext.commands import Cog, Context, command, has_permissions
if TYPE_CHECKING:
from ..core import MinearchyBot
from .. import MinearchyBot
class Moderation(Cog):