Не может определить channel в discord py
Я написал команду, которая ставит реакцию на сообщение и шлёт в отдельный канал сообщение.
import discord
from discord.ext import commands
from discord.ext.commands import Bot
@client.command(name='Report', aliases=['отзыв'], description='логи')
async def report(message):
if message.message.content[10:] == '':
await message.channel.send(embed=discord.Embed(
title="Отзыв",
description='Сюда можно слать ваши пожелания к боту или жалобы на ошибки.',
color=discord.Colour.blue()))
else:
await message.message.add_reaction('?')
message_content = str(message.message.content)
embed = discord.Embed(title='Инфа', description='_ _', colour=discord.Colour.red())
embed.set_author(name=message.author.name, icon_url=message.author.avatar_url)
embed.add_field(name='Содержимое:', value=f'{message_content}', inline=False)
channel = client.get_channel(821809754061013046)
await channel.send(embed=embed)
Но почему-то мне выдаёт ошибку
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 902, in invoke
await ctx.command.invoke(ctx)
File "/app/.heroku/python/lib/python3.6/site-packages/discord/ext/commands/core.py", line 864, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/app/.heroku/python/lib/python3.6/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'сhannel' is not defined
Что мне c этим делать?
Ответы (1 шт):
Автор решения: xZartsust
→ Ссылка
С документации
И я бы посоветовал использовать ctx вместо message или же присвоить тип этой перемене
async def report(message: discord.ContextType)
guild = ctx.message.guild
channel = guild.get_channel(821809754061013046)