Firework
Firework

Reputation: 239

'Object of type TextChannel is not JSON serializable' when trying to create a channel

I'm trying to make it so if a channel is deleted, it will be remade after an hour. But when I use this code:

async def on_guild_channel_delete(channel): 
            guild = channel.guild                   
      await guild.create_text_channel(channel)

It returns: Object of type TextChannel is not JSON serializable

Is there anyway to fix this?

Upvotes: 0

Views: 624

Answers (1)

JacobIRR
JacobIRR

Reputation: 8946

Get the channels name with str:

await guild.create_text_channel(str(channel))

Upvotes: 1

Related Questions