async def execute(ctx, params): guild = ctx['guild'] author = ctx['message'].author vc = ctx['voice_channel'] creator_id = utils.get_creator_id(ctx['settings'], vc) if author.id == creator_id: return False, "You're already the creator." result = await func.set_creator(guild, vc.id, author) return result, None
async def run(c, ctx, params): if c not in commands: if 'dcnf' not in ctx['settings'] or ctx['settings']['dcnf'] is False: similar = sorted(commands, key=lambda x: SequenceMatcher(None, x, c).ratio(), reverse=True)[0] ratio = SequenceMatcher(None, similar, c).ratio() return False, "Sorry, `{}` is not a recognised command.{}".format( c, " Did you mean `{}{}`?".format(ctx['print_prefix'], similar) if ratio > 0.65 else "") else: return False, "NO RESPONSE" cmd = commands[c] if cmd.admin_required and not ctx['admin']: return False, ("Gabisa bikin channel default, cuma admin yg bisa ") restrictions = ctx['settings']['restrictions'] if 'restrictions' in ctx[ 'settings'] else {} if not ctx['admin'] and c in restrictions: roles = [r.id for r in ctx['message'].author.roles] if not any((r in roles) for r in restrictions[c]): return False, "You don't have permission to use that command." if cmd.sapphire_required and not ctx['sapphire']: return False, ( "That command is restricted to :gem: **Sapphire Patron** servers.\n" "Become a Sapphire Patron to support the development of this bot and unlock more ~~useless~~ " "amazing features: https://www.patreon.com/pixaal") elif cmd.gold_required and not ctx['gold']: return False, ( "That command is restricted to :credit_card: **Gold Patron** servers.\n" "Become a Gold Patron to support the development of this bot and unlock more ~~useless~~ " "amazing features: https://www.patreon.com/pixaal") if cmd.voice_required: v = ctx['message'].author.voice if v is not None and v.channel.id in get_secondaries( ctx['guild'], ctx['settings']): ctx['voice_channel'] = v.channel else: return False, "You need to be in one of my voice channels to use that command." if cmd.creator_only: vc = ctx[ 'voice_channel'] # all creator_only commands will also have voice_required creator_id = utils.get_creator_id(ctx['settings'], vc) ctx['creator_id'] = creator_id if not creator_id == ctx['message'].author.id and not ctx['admin']: creator_mention = None for m in vc.members: if m.id == creator_id: creator_mention = m.mention break return False, ( "Only the person who created this voice channel ({}) is allowed to do that.\n" "If you were the creator originally but then left the channel temporarily, " "the person at the top of the channel at the time became the new designated creator." "".format( creator_mention if creator_mention else "unknown member")) if len(params) < cmd.params_required: ctx['incorrect_command_usage'] = False await help_cmd.command.execute(ctx, [c]) return False, None try: r = await cmd.execute(ctx, params) # Run command except discord.errors.Forbidden: return False, "I don't have permission to do that :(" except Exception as e: error_text = "Server: `{}`\n`{}` with command `{}`, params_str: `{}`".format( ctx['guild'].id, type(e).__name__, c, ' '.join(params)) await admin_log(error_text, ctx['client']) log(error_text) import traceback error_text = traceback.format_exc() await admin_log(error_text, ctx['client']) log(error_text) return False, ( "A `{}` error occured :(\n" "Please ensure I have the correct permissions, check `{}help {}` for the correct command usage, " "and then try again. \nIf that still doesn't help, try asking in the support server: " "https://discord.gg/qhMrz6u".format( type(e).__name__, ctx['print_prefix'], c)) if r is None: # In case command didn't return success/response await admin_log( "Server: `{}`\nUnknown Error with command `{}`, params_str: {}". format(ctx['guild'].id, c, ' '.join(params)), ctx['client'], important=True) return False, ( "An unknown error occured :(\n" "Please ensure I have the correct permissions, check `{}help {}` for the correct command usage, " "and then try again. \nIf that still doesn't help, try asking in the support server: " "https://discord.gg/qhMrz6u".format(ctx['print_prefix'], c)) return r
async def execute(ctx, params): params_str = ' '.join(params).strip() guild = ctx['guild'] settings = ctx['settings'] author = ctx['message'].author vc = ctx['voice_channel'] parts = params_str.split('\n', 1) name = parts[0] reason = parts[1] if len(parts) > 1 else None user = utils.get_user_in_channel(name, vc) if not user: return False, "Can't find any user in your channel with the name \"{}\".".format( name) if user.id == utils.get_creator_id(settings, vc): return False, "You cannot kick the creator of this channel." if user == author: return False, "Please don't kick yourself :frowning:" participants = [ m for m in vc.members if m not in [author, user] and not m.bot ] required_votes = floor((len(participants) + 1) / 2) + 1 try: text = ( "‼ **Votekick** ‼\n" "{initiator} has initiated a votekick against {offender}.{reason}\n\n" "{participants}:\nVote by reacting with ✅ to kick {offender}, " "or ignore this message to vote **No**.\n\n" "You have **2 minutes** to vote. A majority vote ({req}/{tot}) is required.\n" "{initiator} your vote is automatically counted. Votes by users not in your channel will be ignored." "".format( initiator=author.mention, offender=user.mention, reason=(" Reason: **{}**".format(reason) if reason else ""), participants=' '.join([m.mention for m in participants]), req=required_votes, tot=len(participants) + 1)) if not participants: text = "..." m = await ctx['message'].channel.send(text) except discord.errors.Forbidden: return False, "I don't have permission to reply to your kick command." cfg.VOTEKICKS[m.id] = { "initiator": author, "participants": participants, "required_votes": required_votes, "offender": user, "reason": reason, "in_favor": [author], "voice_channel": vc, "message": m, "end_time": time() + 120 } try: if participants: await m.add_reaction('✅') except discord.errors.Forbidden: pass await func.server_log( guild, "👢 {} (`{}`) initiated a votekick against **{}** (`{}`) in \"**{}**\". Reason: *{}*." .format(func.user_hash(author), author.id, func.user_hash(user), user.id, vc.name, reason), 1, settings) return True, "NO RESPONSE"