i made a class for my bots config and general things in my code, im tidy so, client is discord.Client() and bot. is my class in my bot class i stored some channel ids and then i noticed client.send_message(channelid, message) way is no longer supporting. however, i edited my channel id variables to
channel1=client.get_channel(channelid)
client=discord.Client() is over my class, its defined.
i used this to send message
await bot.channel1.send("hello world")
i was expecting an message in that channel but reality:
Task exception was never retrieved
future: <Task finished name='Task-2' coro=<bot2() done, defined at /path/to/file/bot.py:46> exception=AttributeError("'NoneType' object has no attribute 'send'")>
Traceback (most recent call last):
File "/path/to/file/bot.py", line 53, in bot2
await bot.channel1.send(fc)
AttributeError: 'NoneType' object has no attribute 'send'
briefly my channel1 definition is nonetype.. why?
and yes i use another async def in my code and run it because this code should run outside on_message() and should run async
i called my async function end of the file with
client.loop.create_task(bot())
client.loop.create_task(bot2())
client.loop.create_task(dead())
client.run(bot.token)
channel1
is defined.bot.channel1
is not defined. – knosmosclass bot: channel1=xxx
– norahCiiself.channel1
? – knosmosbot.channel1
? inside a method? – Ceres