Esempio n. 1
0
 async def print_stacktrace(client, message, stacktrace):
     author = Member(message.author)
     msg = message.content
     guild = Guild(message.guild)
     txt_channel = TextChannel(message.channel)
     spirit_logger.debug(str(stacktrace))
     await txt_channel.send(str(stacktrace))
Esempio n. 2
0
def test_server_info_command(time_since_patch, cog, ctx, moderator_role):
    time_since_patch.return_value = '2 days ago'

    ctx.guild.created_at = datetime(2001, 1, 1)
    ctx.guild.features = ('lemons', 'apples')
    ctx.guild.region = 'The Moon'
    ctx.guild.roles = [moderator_role]
    ctx.guild.channels = [
        TextChannel(state={},
                    guild=ctx.guild,
                    data={
                        'id': 42,
                        'name': 'lemons-offering',
                        'position': 22,
                        'type': 'text'
                    }),
        CategoryChannel(state={},
                        guild=ctx.guild,
                        data={
                            'id': 5125,
                            'name': 'the-lemon-collection',
                            'position': 22,
                            'type': 'category'
                        }),
        VoiceChannel(state={},
                     guild=ctx.guild,
                     data={
                         'id': 15290,
                         'name': 'listen-to-lemon',
                         'position': 22,
                         'type': 'voice'
                     })
    ]
    ctx.guild.members = [
        member('online'),
        member('online'),
        member('idle'),
        member('dnd'),
        member('dnd'),
        member('dnd'),
        member('dnd'),
        member('offline'),
        member('offline'),
        member('offline')
    ]
    ctx.guild.member_count = 1_234
    ctx.guild.icon_url = 'a-lemon.png'

    coroutine = cog.server_info.callback(cog, ctx)
    assert asyncio.run(coroutine) is None  # no rval

    time_since_patch.assert_called_once_with(ctx.guild.created_at,
                                             precision='days')
    _, kwargs = ctx.send.call_args
    embed = kwargs.pop('embed')
    assert embed.colour == Colour.blurple()
    assert embed.description == textwrap.dedent(f"""
        **Server information**
        Created: {time_since_patch.return_value}
        Voice region: {ctx.guild.region}
        Features: {', '.join(ctx.guild.features)}

        **Counts**
        Members: {ctx.guild.member_count:,}
        Roles: {len(ctx.guild.roles)}
        Text: 1
        Voice: 1
        Channel categories: 1

        **Members**
        {Emojis.status_online} 2
        {Emojis.status_idle} 1
        {Emojis.status_dnd} 4
        {Emojis.status_offline} 3
        """)
    assert embed.thumbnail.url == 'a-lemon.png'