#Stacking 2 event listener with the same function issue

1 messages · Page 1 of 1 (latest)

vagrant grail
#
@client.listen(event_name=interactions.events.GuildJoin)
@client.listen(event_name=interactions.events.GuildLeft)
async def on_guild(guild) -> None:
    """Fires when bot joins or leaves a guild."""

    _guild = guild.guild
    current_time: float = round(datetime.utcnow().timestamp())

    embed = interactions.Embed(title=f"{function_name} {_guild.name}")
    embed.add_field(name="ID", value=f"{_guild.id}", inline=True)
    embed.add_field(
        name=f"{function_name} on",
        value=f"<t:{round(current_time)}:F>",
        inline=True,
    )
    embed.add_field(
        name="Member",
        value=f"{_guild.member_count}",
        inline=True,
    )
    if _guild.icon:
        embed.set_thumbnail(url=f"{_guild.icon.url}")

    payload: dict = models.discord.message.process_message_payload(
        embeds=embed
    )
    await client.http.create_message(channel_id=LOG_CHANNEL, payload=payload)

I was just reusing code here, then later will do something to get the current fired decorator and assign the appropriate text inside {function_name}. The issue is I'm getting this error:

    async def on_guild(guild) -> None:
  File "E:\source\Speedy\.venv\lib\site-packages\interactions\models\internal\listener.py", line 79, in wrapper
    raise TypeError("Listener must be a coroutine")
TypeError: Listener must be a coroutine
heavy pathBOT
#

Hey! Once your issue is solved, press the button below to close this thread!