Example #1
0
    async def commandstats(self, ctx, all_stats: bool = False):
        data = self.config.get('data', {})
        if all_stats:
            title = "Bot"
            commands = {}
            for d in data:
                server_cmds = data.get(d, {})
                for c in server_cmds.keys():
                    current = commands.get(c, 0)
                    commands[c] = current + server_cmds[c]
        else:
            title = "This Server"
            commands = data.get(ctx.message.server.id, {})
        commands = OrderedDict(
            sorted(commands.items(), key=lambda x: x[1], reverse=True))

        stats = []
        for c in commands.keys():
            stats.append(c + ": " + str(commands[c]))
        try:
            pager = Pages(self.bot, message=ctx.message, entries=stats)
            pager.embed.colour = Colors.get_default(self.bot)
            pager.embed.set_author(name="Command stats for " + title,
                                   icon_url=ctx.message.server.icon_url)
            await pager.paginate()

        except Exception as e:
            await self.bot.say(e)
Example #2
0
    async def _enable_all(self, ctx, *, target=None):
        """
        Enable a command on the bot. Target can be a member, channel, or role.
        The command will be disabled for the target. If no target is specified,
        it will enable the command for the whole server. If the command
        contains a space you must "wrap it in quotes like this."
        """
        query = target
        target = None
        if query is not None:
            try:
                target = await discord.ext.commands.MemberConverter().convert(
                    ctx, query)
            except discord.ext.commands.errors.MemberNotFound:
                pass
        else:
            target = ctx.channel
        if target is None:
            try:
                target = await discord.ext.commands.TextChannelConverter(
                ).convert(ctx, query)
            except discord.ext.commands.errors.ChannelNotFound:
                pass
        if target is None:
            try:
                target = await discord.ext.commands.RoleConverter().convert(
                    ctx, query)
            except discord.ext.commands.errors.RoleNotFound:
                return await ctx.send(f'I couldn\'t find `{query}`')
        the_for = ' for ' + target.mention
        embed = ctx.embed(
            title='Commands Enabled',
            description=(f'I will now stop ignoring all commands{the_for}.'))

        async with self.bot.pools.config.acquire() as connection:
            data = await connection.fetchrow(
                'SELECT * FROM serverconf WHERE id = $1', ctx.guild.id)
            if not data:
                return await ctx.send(
                    embed=ctx.error(f'Commands are not disabled{the_for}.'))
            else:
                commands = data['commands']
                if isinstance(commands, dict):
                    commands[str(target.id)] = commands.get(str(target.id), [])
                else:
                    return await ctx.send(
                        embed=ctx.error(f'Commands are not disabled{the_for}.')
                    )
                try:
                    commands[str(target.id)].remove(True)
                except ValueError:
                    return await ctx.send(
                        embed=ctx.error(f'Commands are not disabled{the_for}.')
                    )
                await connection.execute(
                    '''UPDATE serverconf
                SET commands = $1::json WHERE id = $2''', commands,
                    ctx.guild.id)
        await self.bot.helpers.prepare(self.bot, ctx.guild)
        await ctx.send(embed=embed)
Example #3
0
async def on_message(ctx):
    msg_content = ctx.content.lower()
    args = msg_content.split(" ")
    if ctx.author is client.user:  # check if the user is a bot
        return
    if args[0] in commands:
        func = commands.get(args[0], lambda: 'Invalid')(ctx, args)
        if Util.is_embed_message(args[0]):
            await ctx.channel.send(embed=func)
        if not Util.is_embed_message(args[0]):
            await ctx.channel.send(func)
        print(f"[LOGS] {ctx.author.name} used {args[0]} command.")
Example #4
0
def on_message(message):
    if message.content.startswith(config.PREFIX):
        invoke = message.content[len(config.PREFIX):].split(" ")[0]
        args = message.content.split(" ")[1:]
        if commands.__contains__(invoke):
            yield from commands.get(invoke).ex(args, message, client, invoke,
                                               config)
        else:
            yield from client.send_message(
                message.channel,
                embed=Embed(color=discord.Color.red(),
                            description=("The command `%s` is not valid!" %
                                         invoke)))
Example #5
0
    async def _disable_all(self, ctx, *, target=None):
        query = target
        target = None
        if query is not None:
            try:
                target = await discord.ext.commands.MemberConverter().convert(
                    ctx, query)
            except discord.ext.commands.errors.MemberNotFound:
                pass
        else:
            target = ctx.channel
        if target is None:
            try:
                target = await discord.ext.commands.TextChannelConverter(
                ).convert(ctx, query)
            except discord.ext.commands.errors.ChannelNotFound:
                pass
        if target is None:
            try:
                target = await discord.ext.commands.RoleConverter().convert(
                    ctx, query)
            except discord.ext.commands.errors.RoleNotFound:
                return await ctx.send(f'I couldn\'t find `{query}`')
        the_for = ' for ' + target.mention
        embed = ctx.embed(
            title='Commands Disabled',
            description=(f'I will now ignore all commands{the_for}.'))

        async with self.bot.pools.config.acquire() as connection:
            data = await connection.fetchrow(
                'SELECT * FROM serverconf WHERE id = $1', ctx.guild.id)
            if not data:
                commands = {str(target.id): [True]}
                await connection.execute(
                    '''INSERT INTO serverconf (id, commands)
                    VALUES ($1, $2::json)''', ctx.guild.id, commands)
            else:
                commands = data['commands']
                if isinstance(commands, dict):
                    commands[str(target.id)] = commands.get(str(target.id), [])
                else:
                    commands = {str(target.id): [True]}
                if True in commands[str(target.id)]:
                    return await ctx.send(embed=ctx.error(
                        f'All commands are already disabled{the_for}.'))
                commands[str(target.id)].append(True)
                await connection.execute(
                    'UPDATE serverconf SET commands = $1::json WHERE id = $2',
                    commands, ctx.guild.id)
        await self.bot.helpers.prepare(self.bot, ctx.guild)
        await ctx.send(embed=embed)
async def on_message(message):
    if not message.content.startswith(prefix) or message.author.bot: return

    args = message.content[len(prefix):].strip().split()
    command = args[0].lower()

    args = args[1:]

    if commands.get(command) == None: return

    try:
        await commands.get(command).execute(message, args)

    except Exception as error:
        await message.channel.send(
            f'{message.author.mention}, There was an error trying to execute that command!'
        )
        raise error
Example #7
0
    async def _internal_aliases(self, ctx, *, args=None):
        commands = {
            'eva':
            '',
            'noop':
            '',
            'quit':
            '',
            'meesterP':
            '!exec !updatelist ;; !airing @me',
            'election':
            f'!say {shared.emote_humm} do you mean `b/election votes`? {shared.emote_humm}',
            'votes':
            f'!say {shared.emote_humm} do you mean `b/election votes`? {shared.emote_humm}'
        }

        args = f' {args}' if args else ''
        ctx.message.content = commands.get(ctx.invoked_with,
                                           '').replace('{args}', args)
        await ctx.bot.process_commands(ctx.message)
Example #8
0
    async def disabled(self, ctx):
        """

        """
        try:
            commands = self.bot.server_cache[ctx.guild.id]['commands']
        except KeyError:
            await self.bot.helpers.prepare(self.bot, ctx.guild)
            commands = self.bot.server_cache[ctx.guild.id]['commands']
        if not commands:
            return await ctx.send(embed=ctx.error('No commands are disabled'))
        if len(commands) == 0:
            return await ctx.send(embed=ctx.error('No commands are disabled'))

        content = ('\n'.join(
            [(await convert(ctx, command)).mention + ': ' +
             (('`' + '`, `'.join(commands[command]) +
               '`.') if True not in commands[command] else 'All Commands')
             for command in commands if commands.get(command, None)])
                   or 'No Commands are disabled')
        await ctx.send(embed=ctx.embed(content, title='Disabled Commands'))
Example #9
0
def on_message(message):
    if message.content.startswith(STATICS.PREFIX):
        invoke = message.content[len(STATICS.PREFIX):].split(" ")[0]
        args = message.content.split(" ")[1:]
        if commands.__contains__(invoke):
            yield from commands.get(invoke).ex(args, message, client, invoke)
        else:
            yield from client.send_message(
                message.channel,
                embed=Embed(color=discord.Color.red(),
                            description=("The command `%s` is not valid!" %
                                         invoke)))
    if message.content.startswith('?user'):
        try:
            user = message.mentions[0]
            userjoinedat = str(user.joined_at).split('.', 1)[0]
            usercreatedat = str(user.created_at).split('.', 1)[0]
            userembed = discord.Embed(title="Username:"******"User Info")
            userembed.add_field(name="Joined the server at:",
                                value=userjoinedat)
            userembed.add_field(name="User Created at:", value=usercreatedat)
            userembed.add_field(name="Discriminator:",
                                value=user.discriminator)
            userembed.add_field(name="User ID:", value=user.id)
            yield from client.send_message(message.channel, embed=userembed)
        except IndexError:
            yield from client.send_message(
                message.channel, "Ich konnte den User nicht finden.")
        except:
            yield from client.send_message(message.channel, "Sorry Error")
        finally:
            pass
    if message.content.startswith('?uptime'):
        yield from client.send_message(
            message.channel,
            "Ich bin schon {0} Tage {1} stunde/n und {2} minuten online auf {3}."
            .format(days, hour, minutes, message.server))
    if message.content.lower().startswith("?test"):
        botmsg = yield from client.send_message(message.channel, "šŸ‘ oder šŸ‘Ž")

        yield from client.add_reaction(botmsg, "šŸ‘")
        yield from client.add_reaction(botmsg, "šŸ‘Ž")

        global testmsgid
        testmsgid = botmsg.id

        global testmsguser
        testmsguser = message.author
    if message.content.lower().startswith("?Teams"):
        embed = discord.Embed(
            title="Command",
            color=600,  # blue
            description=
            "**@Brainhelfer maketeams** [anzahl der spieler] [anzahl der Teams]\n"
            "Dann nach geh in den waiting room und gib join ein\n"
            "am ende wenn alle pƤtze voll sind werden alle gemoved\n"
            "oder mit **closeteams** gemoved wenn nicht alle pƤtze voll sind")
        embed.set_author(
            name="Command list",
            icon_url=
            "http://img1.wikia.nocookie.net/__cb20070302203617/beamer/images/7/71/Zahnrad.png",
            url="https://discordapp.com/developers/applications ")
        embed.set_footer(text="Ein bot von Brainkackwitz")
        embed.set_thumbnail(
            url=
            "http://img1.wikia.nocookie.net/__cb20070302203617/beamer/images/7/71/Zahnrad.png"
        )
        yield from client.send_message(message.channel, embed=embed)
    if message.content.lower().startswith("?teams"):
        embed = discord.Embed(
            title="Command",
            color=600,  # blue
            description=
            "**@Brainhelfer maketeams** [anzahl der spieler] [anzahl der Teams]\n"
            "Dann nach geh in den waiting room und gib join ein\n"
            "am ende wenn alle pƤtze voll sind werden alle gemoved\n"
            "oder mit **closeteams** gemoved wenn nicht alle pƤtze voll sind")
        embed.set_author(
            name="Command list",
            icon_url=
            "http://img1.wikia.nocookie.net/__cb20070302203617/beamer/images/7/71/Zahnrad.png",
            url="https://discordapp.com/developers/applications ")
        embed.set_footer(text="Ein bot von Brainkackwitz")
        embed.set_thumbnail(
            url=
            "http://img1.wikia.nocookie.net/__cb20070302203617/beamer/images/7/71/Zahnrad.png"
        )
        yield from client.send_message(message.channel, embed=embed)
    if message.content.lower().startswith("?Team"):
        embed = discord.Embed(
            title="Command",
            color=600,  # blue
            description=
            "**@Brainhelfer maketeams** [anzahl der spieler] [anzahl der Teams]\n"
            "Dann nach geh in den waiting room und gib join ein\n"
            "am ende wenn alle pƤtze voll sind werden alle gemoved\n"
            "oder mit **closeteams** gemoved wenn nicht alle pƤtze voll sind")
        embed.set_author(
            name="Command list",
            icon_url=
            "http://img1.wikia.nocookie.net/__cb20070302203617/beamer/images/7/71/Zahnrad.png",
            url="https://discordapp.com/developers/applications ")
        embed.set_footer(text="Ein bot von Brainkackwitz")
        embed.set_thumbnail(
            url=
            "http://img1.wikia.nocookie.net/__cb20070302203617/beamer/images/7/71/Zahnrad.png"
        )
        yield from client.send_message(message.channel, embed=embed)
    if message.content.lower().startswith("?team"):
        embed = discord.Embed(
            title="Command",
            color=600,  # blue
            description=
            "**@Brainhelfer maketeams** [anzahl der spieler] [anzahl der Teams]\n"
            "Dann nach geh in den waiting room und gib join ein\n"
            "am ende wenn alle pƤtze voll sind werden alle gemoved\n"
            "oder mit **closeteams** gemoved wenn nicht alle pƤtze voll sind")
        embed.set_author(
            name="Command list",
            icon_url=
            "http://img1.wikia.nocookie.net/__cb20070302203617/beamer/images/7/71/Zahnrad.png",
            url="https://discordapp.com/developers/applications ")
        embed.set_footer(text="Ein bot von Brainkackwitz")
        embed.set_thumbnail(
            url=
            "http://img1.wikia.nocookie.net/__cb20070302203617/beamer/images/7/71/Zahnrad.png"
        )
        yield from client.send_message(message.channel, embed=embed)
    if message.content.lower().startswith("?lol"):

        search = message.content[5:]
        driver = webdriver.Firefox()
        url = "https://euw.op.gg/summoner/userName="******"userName")
        inputElement.send_keys(search)
        inputElement.submit()
        try:
            time.sleep(5)
            elo = str(driver.find_element_by_class_name("TierRank").text)
            lp = str(driver.find_element_by_class_name("LeaguePoints").text)
            winr = str(driver.find_element_by_class_name("winratio").text)
            yield from client.send_message(
                message.channel,
                "Player " + search + "\n" + elo + "\n" + lp + "\n" + winr)

            #driver.find_element_by_xpath('//h3[@class="LC20lb" and not(contains(text(), "org")) and not(contains(text(), "wikipedia"))]').click()

        except:
            serverchannel = discord.Object(STATICS.channelname_Bot_channel)
            yield from client.send_message(message.channel,
                                           "Es gibt einen fehler!")
Example #10
0
async def help(ctx):
    commands = bot.all_commands
    group = commands.get("splitCalculator")
    await ctx.send_help(group)
Example #11
0
    async def _disable_command(self, ctx, command, *, target=None):
        """
        Disable a command on the bot. Target can be a member, channel, or role.
        The command will be disabled for the target. If no target is specified,
        it will disable the command for the whole server. If the command
        contains a space you must "wrap it in quotes like this."
        """
        if target is not None:
            try:
                target = await discord.ext.commands.MemberConverter().convert(
                    ctx, target)
            except discord.ext.commands.errors.MemberNotFound:
                try:
                    target = (
                        await
                        discord.ext.commands.TextChannelConverter()).convert(
                            ctx, target)
                except discord.ext.commands.errors.ChannelNotFound:
                    try:
                        target = (
                            await
                            discord.ext.commands.RoleConverter()).convert(
                                ctx, target)
                    except discord.ext.commands.errors.RoleNotFound:
                        return await ctx.send(f'I couldn\'t find `{target}`')
            the_for = ' for ' + target.mention
        else:
            target = ctx.guild
            the_for = ''
        command = self.bot.get_command(command)
        if not command:
            return await ctx.send(embed=ctx.error('That isn\'t a command!'))
        if command.qualified_name.split()[0] in ['config', 'help']:
            return await ctx.send(embed=ctx.error(
                "You cannot disable the config or help commands."))
        embed = ctx.embed(
            title='Command Disabled',
            description=
            (f'I will now ignore the command {command.qualified_name}{the_for}.'
             ))

        async with self.bot.pools.config.acquire() as connection:
            data = await connection.fetchrow(
                'SELECT * FROM serverconf WHERE id = $1', ctx.guild.id)
            if not data:
                commands = {str(target.id): [command.qualified_name]}
                await connection.execute(
                    '''INSERT INTO serverconf (id, commands)
                    VALUES ($1, $2::json)''', ctx.guild.id, commands)
            else:
                commands = data['commands']
                if isinstance(commands, dict):
                    commands[str(target.id)] = commands.get(str(target.id), [])
                else:
                    commands = {str(target.id): [command.qualified_name]}
                if command.qualified_name in commands[str(target.id)]:
                    return await ctx.send(embed=ctx.error((
                        f'`{command.qualified_name}` is already disabled'
                        f'{the_for}.')))
                commands[str(target.id)].append(command.qualified_name)
                await connection.execute(
                    'UPDATE serverconf SET commands = $1 WHERE id = $2',
                    commands, ctx.guild.id)
        await self.bot.helpers.prepare(self.bot, ctx.guild)
        await ctx.send(embed=embed)
Example #12
0
            return

        responded, result = received
        commands_values = []
        prefix_values = []
        for prefix, bot in itertools.product(result, responded):
            if bot["prefix"] == prefix:
                command = message.content[len(prefix):]
                word, _, _ = command.partition("\n")
                got_command, _, _ = word.partition(" ")
                if got_command:
                    commands_values.append((bot["bot_id"], got_command, 1))
                    
        for x, command, _ in commands_values:
            commands = self.all_bot_commands.setdefault(x, {})
            commands[command] = commands.get(command, 0) + 1
        self.update_compile()
        await self.update_bot_commands(prefix_values, commands_values)

    @commands.Cog.listener("on_message")
    @wait_ready()
    @is_user()
    async def addbot_command_tracker(self, message):
        """Tracks ?addbot command. This is an exact copy of R. Danny code."""
        if message.channel.id not in (559455534965850142, 381963689470984203, 381963705686032394):
            return
        if result := await self.is_valid_addbot(message, check=True):
            confirm = False

            def terms_acceptance(msg):
                nonlocal confirm