Skip to content
This repository has been archived by the owner on Feb 6, 2018. It is now read-only.

Add mban command #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions rowboat/plugins/infractions.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,47 @@ def ban(self, event, user, reason=None):
u=member.user if member else user,
))

@Plugin.command('mban', parser=True, level=CommandLevels.MOD)
@Plugin.parser.add_argument('users', type=long, nargs='+')
@Plugin.parser.add_argument('-r', '--reason', default='', help='reason for modlog')
def mban(self, event, args):
members = []
for user_id in args.users:
member = event.guild.get_member(user_id)
if not member:
raise CommandFail('failed to ban {}, user not found'.format(user_id))

if not self.can_act_on(event, member.id, throw=False):
raise CommandFail('failed to ban {}, invalid permissions'.format(user_id))

members.append(member)

msg = event.msg.reply('Ok, ban {} users for `{}`?'.format(len(members), args.reason or 'no reason'))
msg.chain(False).\
add_reaction(GREEN_TICK_EMOJI).\
add_reaction(RED_TICK_EMOJI)

try:
mra_event = self.wait_for_event(
'MessageReactionAdd',
message_id=msg.id,
conditional=lambda e: (
e.emoji.id in (GREEN_TICK_EMOJI_ID, RED_TICK_EMOJI_ID) and
e.user_id == event.author.id
)).get(timeout=10)
except gevent.Timeout:
return
finally:
msg.delete()

if mra_event.emoji.id != GREEN_TICK_EMOJI_ID:
return

for member in members:
Infraction.ban(self, event, member, args.reason, guild=event.guild)

raise CommandSuccess('banned {} users'.format(len(members)))

@Plugin.command('softban', '<user:user|snowflake> [reason:str...]', level=CommandLevels.MOD)
def softban(self, event, user, reason=None):
"""
Expand Down