Browse Source

Fix .help in DMs, make Robocop call you out when your DMs are blocked

Also limit membercount to guilds
main
Ave Ozkal 2 years ago
parent
commit
840e338ed6
7 changed files with 26 additions and 2 deletions
  1. +10
    -1
      Robocop.py
  2. +4
    -0
      cogs/admin.py
  3. +1
    -0
      cogs/basic.py
  4. +2
    -0
      cogs/lockdown.py
  5. +2
    -0
      cogs/meme.py
  6. +5
    -1
      cogs/mod.py
  7. +2
    -0
      cogs/verification.py

+ 10
- 1
Robocop.py View File

@ -104,9 +104,11 @@ async def on_error(event_method, *args, **kwargs):
@bot.event
async def on_command_error(ctx, error):
error_text = str(error)
log.error(f"Error with \"{ctx.message.content}\" from "
f"\"{ctx.message.author} ({ctx.message.author.id}) "
f"of type {type(error)}: {error}")
f"of type {type(error)}: {error_text}")
if isinstance(error, commands.NoPrivateMessage):
return await ctx.send("This command doesn't work on DMs.")
@ -129,6 +131,13 @@ async def on_command_error(ctx, error):
return await ctx.send(f"{ctx.author.mention}: Check failed. "
"You might not have the right permissions "
"to run this command.")
elif isinstance(error, commands.CommandInvokeError) and\
("Cannot send messages to this user" in error_text):
return await ctx.send(f"{ctx.author.mention}: I can't DM you.\n"
"You might have me blocked or have DMs "
f"blocked globally or for {ctx.guild.name}.\n"
"Please resolve that, then "
"run the command again.")
elif isinstance(error, commands.CommandNotFound):
# Nothing to do when command is not found.
return


+ 4
- 0
cogs/admin.py View File

@ -13,9 +13,13 @@ class AdminCog:
self.previous_eval_code = None
def check_if_staff(ctx):
if not ctx.guild:
return False
return any(r.id in config.staff_role_ids for r in ctx.author.roles)
def check_if_bot_manager(ctx):
if not ctx.guild:
return False
return any(r.id == config.bot_manager_role_id for r in ctx.author.roles)
@commands.guild_only()


+ 1
- 0
cogs/basic.py View File

@ -22,6 +22,7 @@ class Basic:
await ctx.send(f"{targetuser.mention}: A link to the rules "
f"can be found here: {config.rules_url}")
@commands.guild_only()
@commands.command()
async def membercount(self, ctx):
"""Prints the member count of the server."""


+ 2
- 0
cogs/lockdown.py View File

@ -8,6 +8,8 @@ class Lockdown:
self.bot = bot
def check_if_staff(ctx):
if not ctx.guild:
return False
return any(r.id in config.staff_role_ids for r in ctx.author.roles)
@commands.guild_only()


+ 2
- 0
cogs/meme.py View File

@ -14,6 +14,8 @@ class Meme:
self.bot = bot
def check_if_staff_or_ot(ctx):
if not ctx.guild:
return True
is_ot = (ctx.channel.name == "off-topic")
is_staff = any(r.id in config.staff_role_ids for r in ctx.author.roles)
return (is_ot or is_staff)


+ 5
- 1
cogs/mod.py View File

@ -10,9 +10,13 @@ class ModCog:
self.bot = bot
def check_if_staff(ctx):
if not ctx.guild:
return False
return any(r.id in config.staff_role_ids for r in ctx.author.roles)
def check_if_target_is_staff(self, target):
if not ctx.guild:
return False
return any(r.id in config.staff_role_ids for r in target.roles)
async def add_restriction(self, member, rst):
@ -190,7 +194,7 @@ class ModCog:
@commands.guild_only()
@commands.bot_has_permissions(ban_members=True)
@commands.check(check_if_staff)
@commands.command()
@commands.command(alias=["softban"])
async def hackban(self, ctx, target: int, *, reason: str = ""):
"""Bans a user with their ID, doesn't message them, staff only."""
target_user = await self.bot.get_user_info(target)


+ 2
- 0
cogs/verification.py View File

@ -104,6 +104,8 @@ class Verification:
self.bot = bot
def check_if_staff(ctx):
if not ctx.guild:
return False
return any(r.id in config.staff_role_ids for r in ctx.author.roles)
@commands.check(check_if_staff)


Loading…
Cancel
Save