byggmesterPRO
byggmesterPRO

Reputation: 50

on_guild_join discord python why does this not work?

This is my code that initiates ofc when it joins a server.

    @commands.Cog.listener()
    async def on_guild_join(self, guild):
        name = str(guild.name)
        description = str(guild.description)
        member_count = str(guild.member_count)
        channel_count = str(len(guild.channels))
        id = str(guild.id)
        region = str(guild.region)
        embed = discord.Embed(title=tit + " Was invited to " + name)
        if guild.description == True:
            embed.add_field(title="Description", value=description)
        embed.add_field(title="ID", value=id)
        embed.add_field(title="Member Count", value=f"Count: {member_count}")
        embed.add_field(title="Channel Count", value=channel_count)
        embed.add_field(title="Region", value=region)
        embed.set_thumbnail(url=guild.icon_url)
        await guild_channel.send(embed=embed)

This is the error

Ignoring exception in on_guild_join
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.7/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "/home/user/DiscordBots/DefaultRobloxTools/cogs/CommandEvents.py", line 58, in on_guild_join
    embed = discord.Embed(title=tit + " Was invited to " + name)
TypeError: unsupported operand type(s) for +: 'function' and 'str'

What's wrong I do not quite understand this error message.

Upvotes: 0

Views: 90

Answers (1)

SaGaR
SaGaR

Reputation: 542

You are assigning the string in wrong format it should be

embed = discord.Embed(title=(tit + " Was invited to " + name))

instead of

embed = discord.Embed(title=tit + " Was invited to " + name)

Upvotes: 1

Related Questions