@qqeuf

SyntaxError 'await' outside function как пофиксить?

import discord

intents = discord.Intents.default()
intents.typing = False
intents.presences = False

client = discord.Client(intents=intents)

@client.event
async def on_message(message):
source_guild_id = 829149586370330634
source_channel_id = 1035244464907767849
target_guild_id = 1182940085751132220
target_channel_id = 1183012496173445183

if message.guild.id == source_guild_id and message.channel.id == source_channel_id:
target_guild = client.get_guild(target_guild_id)
target_channel = target_guild.get_channel(target_channel_id)

if target_channel:
await target_channel.send(f'{message.author.name} в {message.channel.name} написал:\n{message.content}')

client.run('....')

ошибка в этой части:
if target_channel:
await target_channel.send(f'{message.author.name} в {message.channel.name} написал:\n{message.content}')
  • Вопрос задан
  • 74 просмотра
Решения вопроса 1
sergey-gornostaev
@sergey-gornostaev Куратор тега Python
Седой и строгий
Всего лишь правильно расставить отступы.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы