jack1142 97d77f5c51
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
2020-03-28 23:24:12 +01:00

26 lines
772 B
Python

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)