Globally ensure send_messages for commands (#3361)

* wew

* typo fix, thanks Danny
This commit is contained in:
Michael H 2020-01-14 17:42:40 -05:00 committed by GitHub
parent 79dcd22ff6
commit a7f0e2b7c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,7 +4,17 @@ from . import commands
def init_global_checks(bot): def init_global_checks(bot):
@bot.check_once @bot.check_once
def actually_up(ctx): def minimum_bot_perms(ctx) -> bool:
"""
Too many 403, 401, and 429 Errors can cause bots to get global'd
It's reasonable to assume the below as a minimum amount of perms for
commands.
"""
return ctx.channel.permissions_for(ctx.me).send_messages
@bot.check_once
def actually_up(ctx) -> bool:
""" """
Uptime is set during the initial startup process. Uptime is set during the initial startup process.
If this hasn't been set, we should assume the bot isn't ready yet. If this hasn't been set, we should assume the bot isn't ready yet.
@ -12,10 +22,10 @@ def init_global_checks(bot):
return ctx.bot.uptime is not None return ctx.bot.uptime is not None
@bot.check_once @bot.check_once
async def whiteblacklist_checks(ctx): async def whiteblacklist_checks(ctx) -> bool:
return await ctx.bot.allowed_by_whitelist_blacklist(ctx.author) return await ctx.bot.allowed_by_whitelist_blacklist(ctx.author)
@bot.check_once @bot.check_once
def bots(ctx): def bots(ctx) -> bool:
"""Check the user is not another bot.""" """Check the user is not another bot."""
return not ctx.author.bot return not ctx.author.bot