I'm trying to write a discord bot that checks for the word "pawel" in every message sent and if it finds one, it should send a message to a discord text channel called #pawel. If there isn't one it should create it. Right now I'm stuck with this stupid error:
We're live!
Ignoring exception in on_message
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 22, in on_message
channel = discord.utils.get(guild.text_channels, name='pawel')
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/utils.py", line 269, in get
for elem in iterable:
TypeError: 'property' object is not iterable
The full code for the bot down here:
import discord
import os
client = discord.Client()
guild = discord.Guild
@client.event
async def on_ready():
print("We're live!")
pawel = ('pawel')
@client.event
async def on_message(message):
if message.author == client.user:
return
if pawel in message.content:
channel = discord.utils.get(guild.text_channels, name='pawel')
channel.id = channel.id
if channel == None:
await guild.create.text_channel('pawel')
await message.channel.send('pawel')
client.run(os.getenv('TOKEN'))
I've tried everything!