mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-08 12:18:54 -05:00
[V3 Warnings] fix several bugs found (#1577)
This commit is contained in:
parent
79676c4f72
commit
e4ea3110e3
@ -17,8 +17,8 @@ async def warning_points_add_check(config: Config, ctx: RedContext, user: discor
|
||||
act = {}
|
||||
async with guild_settings.actions() as registered_actions:
|
||||
for a in registered_actions:
|
||||
if points >= registered_actions[a]["point_count"]:
|
||||
act = registered_actions[a]
|
||||
if points >= a["points"]:
|
||||
act = a
|
||||
else:
|
||||
break
|
||||
if act: # some action needs to be taken
|
||||
@ -31,8 +31,8 @@ async def warning_points_remove_check(config: Config, ctx: RedContext, user: dis
|
||||
act = {}
|
||||
async with guild_settings.actions() as registered_actions:
|
||||
for a in registered_actions:
|
||||
if points >= registered_actions[a]["point_count"]:
|
||||
act = registered_actions[a]
|
||||
if points >= a["points"]:
|
||||
act = a
|
||||
else:
|
||||
break
|
||||
if act: # some action needs to be taken
|
||||
|
||||
@ -120,7 +120,7 @@ class Warnings:
|
||||
registered_actions.append(to_add)
|
||||
# Sort in descending order by point count for ease in
|
||||
# finding the highest possible action to take
|
||||
registered_actions.sort(key=lambda a: a["point_count"], reverse=True)
|
||||
registered_actions.sort(key=lambda a: a["points"], reverse=True)
|
||||
await ctx.tick()
|
||||
|
||||
@warnaction.command(name="del")
|
||||
@ -137,6 +137,11 @@ class Warnings:
|
||||
break
|
||||
if to_remove:
|
||||
registered_actions.remove(to_remove)
|
||||
await ctx.tick()
|
||||
else:
|
||||
await ctx.send(
|
||||
_("No action named {} exists!").format(action_name)
|
||||
)
|
||||
|
||||
@commands.group()
|
||||
@commands.guild_only()
|
||||
@ -178,7 +183,7 @@ class Warnings:
|
||||
guild_settings = self.config.guild(guild)
|
||||
async with guild_settings.reasons() as registered_reasons:
|
||||
if registered_reasons.pop(reason_name.lower(), None):
|
||||
await ctx.send(_("Removed reason {}").format(reason_name))
|
||||
await ctx.tick()
|
||||
else:
|
||||
await ctx.send(_("That is not a registered reason name"))
|
||||
|
||||
@ -191,13 +196,16 @@ class Warnings:
|
||||
guild_settings = self.config.guild(guild)
|
||||
msg_list = []
|
||||
async with guild_settings.reasons() as registered_reasons:
|
||||
for r in registered_reasons.keys():
|
||||
for r, v in registered_reasons.items():
|
||||
msg_list.append(
|
||||
"Name: {}\nPoints: {}\nAction: {}".format(
|
||||
r, r["points"], r["action"]
|
||||
"Name: {}\nPoints: {}\nDescription: {}".format(
|
||||
r, v["points"], v["description"]
|
||||
)
|
||||
)
|
||||
await ctx.send_interactive(msg_list)
|
||||
if msg_list:
|
||||
await ctx.send_interactive(msg_list)
|
||||
else:
|
||||
await ctx.send(_("There are no reasons configured!"))
|
||||
|
||||
@commands.command()
|
||||
@commands.guild_only()
|
||||
@ -210,11 +218,16 @@ class Warnings:
|
||||
async with guild_settings.actions() as registered_actions:
|
||||
for r in registered_actions:
|
||||
msg_list.append(
|
||||
"Name: {}\nPoints: {}\nDescription: {}".format(
|
||||
r, r["points"], r["description"]
|
||||
"Name: {}\nPoints: {}\nExceed command: {}\n"
|
||||
"Drop command: {}".format(
|
||||
r["action_name"], r["points"], r["exceed_command"],
|
||||
r["drop_command"]
|
||||
)
|
||||
)
|
||||
await ctx.send_interactive(msg_list)
|
||||
if msg_list:
|
||||
await ctx.send_interactive(msg_list)
|
||||
else:
|
||||
await ctx.send(_("There are no actions configured!"))
|
||||
|
||||
@commands.command()
|
||||
@commands.guild_only()
|
||||
@ -271,7 +284,7 @@ class Warnings:
|
||||
if userid is None:
|
||||
user = ctx.author
|
||||
else:
|
||||
if not is_admin_or_superior(self.bot, ctx.author):
|
||||
if not await is_admin_or_superior(self.bot, ctx.author):
|
||||
await ctx.send(
|
||||
warning(
|
||||
_("You are not allowed to check "
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user