W
W
wz2021-07-16 22:49:35
Python
wz, 2021-07-16 22:49:35

Weird discord.py error?

I am writing code for information about the server, but the bot simply ignores, there are no errors.

# server
@bot.command()
async def server(ctx):
    find_bots = sum(1 for member in ctx.guild.members if member.bot)
    members = len([m for m in ctx.guild.members if not m.bot])
    categories = len(ctx.guild.text_channels + ctx.guild.voice_channels)
    channels = len(ctx.guild.text_channels)
    voices = len(ctx.guild.voice_channels)

    e = discord.Embed(title=f"Information about {ctx.guild.name}", color = color, timestamp = ctx.message.created_at)

    if ctx.guild.banner:
        e.add_image(url=ctx.guild.banner_url)

    e.set_thumbnail(url=ctx.guild.icon_url)
    e.add_field(
        name="About members", 
        value=f"""
        <:members_total:865163555614228481> Total: {ctx.guild.members}
        <:bot:865163555878469652> Bots: {find_bots}
        <:members:865163555698245652> Members: {members}""", inline=True)
    e.add_field(
        name="About channels", 
        value=f"""
        <:members_total:865163555614228481> Categories: {categories}
        <:bot:865163555878469652> Channels: {channels}
        <:members:865163555698245652> Voices: {voices}""", inline=True)
    e.add_field(name="Owner", value=ctx.guild.owner, inline=True)
    e.add_field(name="Регион", value=ctx.guild.region, inline=True)
    e.add_field(name="Создан", value=default.date(ctx.guild.created_at), inline=True)
    e.add_field(name="Текст каналов", value=len(ctx.guild.text_channels), inline=True)
    e.add_field(name="Голосовых каналов", value=len(ctx.guild.voice_channels), inline=True)
    e.set_footer(text = f'Requested by: {ctx.author.name}', icon_url = ctx.author.avatar_url)
    await ctx.reply(embed=e, mention_author=False)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-07-16
@Vindicar

Try to wrap the code in try: catch: with error text output, and arrange debug prints. So at least you will understand whether control is transferred to the handler at all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question