mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-23 03:08:01 -05:00
Make checks in Bank, Economy and Trivia cogs Permissions-friendly (#3672)
* Create converters.py * Update trivia.py * Create checks.py * Update checks.py * Update checks.py * Update trivia.py * Update checks.py * Update checks.py * Update trivia.py * Update bank.py * Update economy.py * Update trivia.py * Update checks.py * Update checks.py * Update __init__.py
This commit is contained in:
25
redbot/cogs/trivia/checks.py
Normal file
25
redbot/cogs/trivia/checks.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from redbot.core import commands
|
||||
from redbot.core.i18n import Translator
|
||||
|
||||
__all__ = ("trivia_stop_check",)
|
||||
|
||||
_ = Translator("Trivia", __file__)
|
||||
|
||||
|
||||
def trivia_stop_check():
|
||||
async def predicate(ctx: commands.GuildContext) -> bool:
|
||||
session = ctx.cog._get_trivia_session(ctx.channel)
|
||||
if session is None:
|
||||
raise commands.CheckFailure(_("There is no ongoing trivia session in this channel."))
|
||||
|
||||
author = ctx.author
|
||||
auth_checks = (
|
||||
await ctx.bot.is_owner(author),
|
||||
await ctx.bot.is_mod(author),
|
||||
await ctx.bot.is_admin(author),
|
||||
author == ctx.guild.owner,
|
||||
author == session.ctx.author,
|
||||
)
|
||||
return any(auth_checks)
|
||||
|
||||
return commands.permissions_check(predicate)
|
||||
Reference in New Issue
Block a user