Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @bot.command(pass_context=True)
- async def mute(context):
- if len(context.message.content.split()) < 2:
- await send_message(channel=context.message.channel,
- message='Syntax: a!mute [hours] @Person1... @Person99')
- return
- hours = context.message.content.split()[1]
- hours = float(hours) if hours.replace('.', '').isnumeric() else None
- if hours is not None and not 0 < hours <= 24:
- await send_message(channel=context.message.channel,
- message='Can only mute between 1 - 24 hours')
- return
- mentions = context.message.mentions
- if not mentions:
- await send_message(channel=context.message.channel,
- message='You must mention a person for this command.')
- return
- for mention in mentions:
- if hours:
- hours_string = ''
- if hours >= 1:
- hours_string = ' {hours} hours'.format(hours=int(hours))
- minutes_string = ''
- minutes = (hours - int(hours)) * 60
- if int(minutes):
- if hours_string:
- minutes_string += ' and'
- minutes_string += ' {minutes} minutes'.format(minutes=int(minutes))
- seconds_string = ''
- seconds = (minutes - int(minutes)) * 60
- if seconds:
- if hours_string:
- seconds_string += ' and'
- seconds_string += ' {seconds} seconds'.format(seconds=int(seconds))
- await send_message(channel=context.message.channel,
- message='Muting {mention} for{hours}{minutes}{seconds}!',
- mention=mention,
- hours=hours_string,
- minutes=minutes_string,
- seconds=seconds_string),
- else:
- await send_message(channel=context.message.channel,
- message='Muting {mention} permanently!',
- mention=mention)
- await bot.server_voice_state(member=mention,
- mute=True)
- if hours:
- duration = hours * 3600
- await asyncio.sleep(duration)
- for mention in context.message.mentions:
- await send_message(channel=context.message.channel,
- message='Time is up, unmuting {mention}.',
- mention=mention)
- await bot.server_voice_state(member=mention,
- mute=False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement