mirror of
https://github.com/miaowware/qrm2.git
synced 2025-02-03 09:44:07 -05:00
Merge pull request #290 from miaowware/error
Fixed numerous small potential bugs
This commit is contained in:
commit
e8bb18ea8c
@ -15,11 +15,13 @@ import traceback
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
from typing import Union
|
||||
|
||||
import aiohttp
|
||||
|
||||
import discord
|
||||
import discord.ext.commands as commands
|
||||
from discord import Emoji, Reaction, PartialEmoji
|
||||
|
||||
import data.options as opt
|
||||
|
||||
@ -149,7 +151,7 @@ class GlobalChannelConverter(commands.IDConverter):
|
||||
def embed_factory(ctx: commands.Context) -> discord.Embed:
|
||||
"""Creates an embed with neutral colour and standard footer."""
|
||||
embed = discord.Embed(timestamp=datetime.utcnow(), colour=colours.neutral)
|
||||
embed.set_footer(text=ctx.author, icon_url=str(ctx.author.avatar_url))
|
||||
embed.set_footer(text=str(ctx.author), icon_url=str(ctx.author.avatar_url))
|
||||
return embed
|
||||
|
||||
|
||||
@ -166,11 +168,12 @@ def error_embed_factory(ctx: commands.Context, exception: Exception, debug_mode:
|
||||
return embed
|
||||
|
||||
|
||||
async def add_react(msg: discord.Message, react: str):
|
||||
async def add_react(msg: discord.Message, react: Union[Emoji, Reaction, PartialEmoji, str]):
|
||||
try:
|
||||
await msg.add_reaction(react)
|
||||
except discord.Forbidden:
|
||||
print(f"[!!] Missing permissions to add reaction in '{msg.guild.id}/{msg.channel.id}'!")
|
||||
idpath = (f"{msg.guild.id}/" if msg.guild else "") + str(msg.channel.id)
|
||||
print(f"[!!] Missing permissions to add reaction in '{idpath}'!")
|
||||
|
||||
|
||||
# --- Checks ---
|
||||
|
4
main.py
4
main.py
@ -100,7 +100,7 @@ async def _extctl(ctx: commands.Context):
|
||||
"""Extension control commands.
|
||||
Defaults to `list` if no subcommand specified"""
|
||||
if ctx.invoked_subcommand is None:
|
||||
cmd = bot.get_command("extctl list")
|
||||
cmd = _extctl_list
|
||||
await ctx.invoke(cmd)
|
||||
|
||||
|
||||
@ -168,7 +168,7 @@ async def on_command_error(ctx: commands.Context, err: commands.CommandError):
|
||||
await cmn.add_react(ctx.message, cmn.emojis.warning)
|
||||
await ctx.send_help(ctx.command)
|
||||
elif isinstance(err, commands.CommandNotFound):
|
||||
if ctx.invoked_with.startswith(("?", "!")):
|
||||
if ctx.invoked_with and ctx.invoked_with.startswith(("?", "!")):
|
||||
return
|
||||
else:
|
||||
await cmn.add_react(ctx.message, cmn.emojis.question)
|
||||
|
Loading…
Reference in New Issue
Block a user