aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/backend
diff options
context:
space:
mode:
Diffstat (limited to 'bot/exts/backend')
-rw-r--r--bot/exts/backend/branding/_cog.py18
-rw-r--r--bot/exts/backend/config_verifier.py2
-rw-r--r--bot/exts/backend/error_handler.py30
-rw-r--r--bot/exts/backend/logging.py4
-rw-r--r--bot/exts/backend/sync/_cog.py6
-rw-r--r--bot/exts/backend/sync/_syncers.py4
6 files changed, 27 insertions, 37 deletions
diff --git a/bot/exts/backend/branding/_cog.py b/bot/exts/backend/branding/_cog.py
index 0c5839a7a..a07e70d58 100644
--- a/bot/exts/backend/branding/_cog.py
+++ b/bot/exts/backend/branding/_cog.py
@@ -7,10 +7,10 @@ from enum import Enum
from operator import attrgetter
import async_timeout
-import discord
+import disnake
from arrow import Arrow
from async_rediscache import RedisCache
-from discord.ext import commands, tasks
+from disnake.ext import commands, tasks
from bot.bot import Bot
from bot.constants import Branding as BrandingConfig, Channels, Colours, Guild, MODERATION_ROLES
@@ -42,7 +42,7 @@ def compound_hash(objects: t.Iterable[RemoteObject]) -> str:
return "-".join(item.sha for item in objects)
-def make_embed(title: str, description: str, *, success: bool) -> discord.Embed:
+def make_embed(title: str, description: str, *, success: bool) -> disnake.Embed:
"""
Construct simple response embed.
@@ -51,7 +51,7 @@ def make_embed(title: str, description: str, *, success: bool) -> discord.Embed:
For both `title` and `description`, empty string are valid values ~ fields will be empty.
"""
colour = Colours.soft_green if success else Colours.soft_red
- return discord.Embed(title=title[:256], description=description[:4096], colour=colour)
+ return disnake.Embed(title=title[:256], description=description[:4096], colour=colour)
def extract_event_duration(event: Event) -> str:
@@ -147,13 +147,13 @@ class Branding(commands.Cog):
return False
await self.bot.wait_until_guild_available()
- pydis: discord.Guild = self.bot.get_guild(Guild.id)
+ pydis: disnake.Guild = self.bot.get_guild(Guild.id)
timeout = 10 # Seconds.
try:
with async_timeout.timeout(timeout): # Raise after `timeout` seconds.
await pydis.edit(**{asset_type.value: file})
- except discord.HTTPException:
+ except disnake.HTTPException:
log.exception("Asset upload to Discord failed.")
return False
except asyncio.TimeoutError:
@@ -277,7 +277,7 @@ class Branding(commands.Cog):
log.debug(f"Sending event information event to channel: {channel_id} ({is_notification=}).")
await self.bot.wait_until_guild_available()
- channel: t.Optional[discord.TextChannel] = self.bot.get_channel(channel_id)
+ channel: t.Optional[disnake.TextChannel] = self.bot.get_channel(channel_id)
if channel is None:
log.warning(f"Cannot send event information: channel {channel_id} not found!")
@@ -294,7 +294,7 @@ class Branding(commands.Cog):
else:
content = "Python Discord is entering a new event!" if is_notification else None
- embed = discord.Embed(description=description[:4096], colour=discord.Colour.og_blurple())
+ embed = disnake.Embed(description=description[:4096], colour=disnake.Colour.og_blurple())
embed.set_footer(text=duration[:4096])
await channel.send(content=content, embed=embed)
@@ -573,7 +573,7 @@ class Branding(commands.Cog):
await ctx.send(embed=resp)
return
- embed = discord.Embed(title="Current event calendar", colour=discord.Colour.og_blurple())
+ embed = disnake.Embed(title="Current event calendar", colour=disnake.Colour.og_blurple())
# Because Discord embeds can only contain up to 25 fields, we only show the first 25.
first_25 = list(available_events.items())[:25]
diff --git a/bot/exts/backend/config_verifier.py b/bot/exts/backend/config_verifier.py
index dc85a65a2..1ade2bce7 100644
--- a/bot/exts/backend/config_verifier.py
+++ b/bot/exts/backend/config_verifier.py
@@ -1,4 +1,4 @@
-from discord.ext.commands import Cog
+from disnake.ext.commands import Cog
from bot import constants
from bot.bot import Bot
diff --git a/bot/exts/backend/error_handler.py b/bot/exts/backend/error_handler.py
index 6ab6634a6..953843a77 100644
--- a/bot/exts/backend/error_handler.py
+++ b/bot/exts/backend/error_handler.py
@@ -1,14 +1,12 @@
import difflib
-import typing as t
-from discord import Embed
-from discord.ext.commands import ChannelNotFound, Cog, Context, TextChannelConverter, VoiceChannelConverter, errors
+from disnake import Embed
+from disnake.ext.commands import ChannelNotFound, Cog, Context, TextChannelConverter, VoiceChannelConverter, errors
from sentry_sdk import push_scope
from bot.api import ResponseCodeError
from bot.bot import Bot
from bot.constants import Colours, Icons, MODERATION_ROLES
-from bot.converters import TagNameConverter
from bot.errors import InvalidInfractedUserError, LockedResourceError
from bot.log import get_logger
from bot.utils.checks import ContextCheckFailure
@@ -97,13 +95,14 @@ class ErrorHandler(Cog):
# MaxConcurrencyReached, ExtensionError
await self.handle_unexpected_error(ctx, e)
- @staticmethod
- def get_help_command(ctx: Context) -> t.Coroutine:
+ async def send_command_help(self, ctx: Context) -> None:
"""Return a prepared `help` command invocation coroutine."""
if ctx.command:
- return ctx.send_help(ctx.command)
+ self.bot.help_command.context = ctx
+ await ctx.send_help(ctx.command)
+ return
- return ctx.send_help()
+ await ctx.send_help()
async def try_silence(self, ctx: Context) -> bool:
"""
@@ -174,16 +173,8 @@ class ErrorHandler(Cog):
await self.on_command_error(ctx, tag_error)
return
- try:
- tag_name = await TagNameConverter.convert(ctx, ctx.invoked_with)
- except errors.BadArgument:
- log.debug(
- f"{ctx.author} tried to use an invalid command "
- f"and the fallback tag failed validation in TagNameConverter."
- )
- else:
- if await ctx.invoke(tags_get_command, tag_name=tag_name):
- return
+ if await ctx.invoke(tags_get_command, argument_string=ctx.message.content):
+ return
if not any(role.id in MODERATION_ROLES for role in ctx.author.roles):
await self.send_command_suggestion(ctx, ctx.invoked_with)
@@ -245,7 +236,6 @@ class ErrorHandler(Cog):
elif isinstance(e, errors.ArgumentParsingError):
embed = self._get_error_embed("Argument parsing error", str(e))
await ctx.send(embed=embed)
- self.get_help_command(ctx).close()
self.bot.stats.incr("errors.argument_parsing_error")
return
else:
@@ -256,7 +246,7 @@ class ErrorHandler(Cog):
self.bot.stats.incr("errors.other_user_input_error")
await ctx.send(embed=embed)
- await self.get_help_command(ctx)
+ await self.send_command_help(ctx)
@staticmethod
async def handle_check_failure(ctx: Context, e: errors.CheckFailure) -> None:
diff --git a/bot/exts/backend/logging.py b/bot/exts/backend/logging.py
index 2d03cd580..040fb5d37 100644
--- a/bot/exts/backend/logging.py
+++ b/bot/exts/backend/logging.py
@@ -1,5 +1,5 @@
-from discord import Embed
-from discord.ext.commands import Cog
+from disnake import Embed
+from disnake.ext.commands import Cog
from bot.bot import Bot
from bot.constants import Channels, DEBUG_MODE
diff --git a/bot/exts/backend/sync/_cog.py b/bot/exts/backend/sync/_cog.py
index 80f5750bc..d08e56077 100644
--- a/bot/exts/backend/sync/_cog.py
+++ b/bot/exts/backend/sync/_cog.py
@@ -1,8 +1,8 @@
from typing import Any, Dict
-from discord import Member, Role, User
-from discord.ext import commands
-from discord.ext.commands import Cog, Context
+from disnake import Member, Role, User
+from disnake.ext import commands
+from disnake.ext.commands import Cog, Context
from bot import constants
from bot.api import ResponseCodeError
diff --git a/bot/exts/backend/sync/_syncers.py b/bot/exts/backend/sync/_syncers.py
index 45301b098..48ee3c842 100644
--- a/bot/exts/backend/sync/_syncers.py
+++ b/bot/exts/backend/sync/_syncers.py
@@ -2,8 +2,8 @@ import abc
import typing as t
from collections import namedtuple
-from discord import Guild
-from discord.ext.commands import Context
+from disnake import Guild
+from disnake.ext.commands import Context
from more_itertools import chunked
import bot