mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
Fix no message when unregistered reason is used in [p]warn (#3840)
This commit is contained in:
parent
1ee32b77dd
commit
500f91f0cd
@ -1,5 +1,6 @@
|
|||||||
import contextlib
|
import contextlib
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
from copy import copy
|
||||||
from typing import Union, Optional
|
from typing import Union, Optional
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
@ -350,22 +351,27 @@ class Warnings(commands.Cog):
|
|||||||
|
|
||||||
reason_type = None
|
reason_type = None
|
||||||
async with self.config.guild(ctx.guild).reasons() as registered_reasons:
|
async with self.config.guild(ctx.guild).reasons() as registered_reasons:
|
||||||
if reason.lower() not in registered_reasons:
|
if (reason_type := registered_reasons.get(reason.lower())) is None:
|
||||||
msg = _("That is not a registered reason!")
|
msg = _("That is not a registered reason!")
|
||||||
if custom_allowed:
|
if custom_allowed:
|
||||||
reason_type = {"description": reason, "points": points}
|
reason_type = {"description": reason, "points": points}
|
||||||
elif (
|
else:
|
||||||
ctx.guild.owner == ctx.author
|
# logic taken from `[p]permissions canrun`
|
||||||
or ctx.channel.permissions_for(ctx.author).administrator
|
fake_message = copy(ctx.message)
|
||||||
or await ctx.bot.is_owner(ctx.author)
|
fake_message.content = f"{ctx.prefix}warningset allowcustomreasons"
|
||||||
):
|
fake_context = await ctx.bot.get_context(fake_message)
|
||||||
msg += " " + _(
|
try:
|
||||||
"Do `{prefix}warningset allowcustomreasons true` to enable custom "
|
can = await self.allowcustomreasons.can_run(
|
||||||
"reasons."
|
fake_context, check_all_parents=True, change_permission_state=False
|
||||||
).format(prefix=ctx.clean_prefix)
|
)
|
||||||
|
except commands.CommandError:
|
||||||
|
can = False
|
||||||
|
if can:
|
||||||
|
msg += " " + _(
|
||||||
|
"Do `{prefix}warningset allowcustomreasons true` to enable custom "
|
||||||
|
"reasons."
|
||||||
|
).format(prefix=ctx.clean_prefix)
|
||||||
return await ctx.send(msg)
|
return await ctx.send(msg)
|
||||||
else:
|
|
||||||
reason_type = registered_reasons[reason.lower()]
|
|
||||||
if reason_type is None:
|
if reason_type is None:
|
||||||
return
|
return
|
||||||
member_settings = self.config.member(user)
|
member_settings = self.config.member(user)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user