A
A
Artur Orlyk2022-03-26 21:25:49
Python
Artur Orlyk, 2022-03-26 21:25:49

When joining the bot to the server, it should send a message to the system chat or to the creator's PM, but instead an error is displayed. What to do?

I made a command so that when the bot was added to the server, it displayed in the system chat or in the PM a message was created: Hello! My prefix = m!. But this does not happen, the error is displayed in the console:

C:\Users\Artur\AppData\Local\Discord\Bots-Settings\my_server\Mayuko\bot\main.py:129: RuntimeWarning: coroutine 'send_override' was never awaited
guild.system_channel .send('Hi! My prefix = m!')
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Here is the code:

@client.event
async def on_guild_join(guild):
    if guild.system_channel is not None:
        guild.system_channel.send('Привет! Мой префикс = m!')
    elif guild.system_channel is None:
        user = client.get_user(guild.owner.id)
        user.send('Привет! Мой префикс = m!')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artur Orlik, 2022-03-27
@Progger228

The problem was that I was trying to run an asynchronous function as if it were not asynchronous.
await user.send('Привет! Мой префикс = m!')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question