Exemple #1
0
    async def ignore(self,
                     ctx,
                     channels: commands.Greedy[discord.TextChannel] = None):
        logger.info("command: invite")

        added = ""
        removed = ""
        if channels is not None:
            logger.info(f"ignored channels: {[c.name for c in channels]}")
            for channel in channels:
                if database.zscore("ignore:global", str(channel.id)) is None:
                    added += f"`#{channel.name}` (`{channel.category.name if channel.category else 'No Category'}`)\n"
                    database.zadd("ignore:global",
                                  {str(channel.id): ctx.guild.id})
                else:
                    removed += f"`#{channel.name}` (`{channel.category.name if channel.category else 'No Category'}`)\n"
                    database.zrem("ignore:global", str(channel.id))
        else:
            await ctx.send("**No valid channels were passed.**")

        ignored = "".join([
            f"`#{channel.name}` (`{channel.category.name if channel.category else 'No Category'}`)\n"
            for channel in map(
                lambda c: ctx.guild.get_channel(int(c)),
                database.zrangebyscore("ignore:global", ctx.guild.id -
                                       0.1, ctx.guild.id + 0.1),
            )
        ])

        await ctx.send(
            (f"**Ignoring:**\n{added}" if added else "") +
            (f"**Stopped ignoring:**\n{removed}" if removed else "") +
            (f"**Ignored Channels:**\n{ignored}" if ignored else
             "**No channels in this server are currently ignored.**"))
Exemple #2
0
async def get_all_users(bot):
    logger.info("Starting user cache")
    user_ids = map(int, database.zrangebyscore("users:global", "-inf", "+inf"))
    for user_id in user_ids:
        await fetch_get_user(user_id, bot=bot, member=False)
    logger.info("User cache finished")