请不要说“已经回答”,因为我尝试了一切,包括此处的所有相关文章,而且显然是在阅读api文档。
完全错误是:
忽略on_ready中的异常 追溯(最近一次通话): _run_event中的文件“ /usr/local/lib/python3.8/dist-packages/discord/client.py”,第312行 等待科罗(* args,** kwargs) 在on_ready中,文件“ embbed_shop.py”,第26行 等待channel.send_message(embed = embed) AttributeError:“ NoneType”对象没有属性“ send_message”
这是我完整的代码(令牌除外):
import discord
from discord.ext import commands
import datetime
import asyncio
import time
from urllib import parse, request
import re
bot = discord.Client()
@bot.event
async def on_ready():
embed = discord.Embed(title="Le SHOP de POIDSPLUME", colour=discord.Colour(0xff9e26), url="https://discordapp.com", description="```yaml\n \t\t\t\t CASSIMON vs ENDER```", timestamp=datetime.datetime.utcfromtimestamp(1593927421))
embed.set_image(url="https://vignette.wikia.nocookie.net/bokunoheroacademia/images/d/d8/Class_1-A_vs._Mirio_Togata_Anime.png/revision/latest?cb=20181001113201")
embed.set_thumbnail(url="https://i.pinimg.com/564x/d5/76/60/d576605d7afc2387757862d9916ea911.jpg")
embed.set_author(name="Poidsplume SHOP", icon_url="https://cdn.discordapp.com/embed/avatars/0.png")
embed.set_footer(text="Powered by @Poidsplume (La Banque)", icon_url="https://i.pinimg.com/564x/d5/76/60/d576605d7afc2387757862d9916ea911.jpg")
embed.add_field(name=" __Achats Cassimon__ ", value="- 1000 pokédollars :dollar: = 200 <:perfectprism:726002243677192283> __ou__ 80 <:Antimater:726002322127454227> \n-1 Pokémon SH qui méga ou giga = 2k <:Antimater:726002322127454227> ou équivalent ", inline=True)
embed.add_field(name="__Ventes Cassimon__ ", value="Les pokémons en vente sont tous à __1500__ pokédollars :dollar: : \n\n x1 Mouscoto <:mouscoto:729241671899938826> \n x1 Ho-oh <:ho_oh_1:729240842518134795> \n x1 Régirock <:regirock:729241757803348000> \n x1 Necrozma Crinière du couchant <:necrozma_criniere:729241703273463830> \n\n\nx1 Hélionceau SH <:helionceau:729242441206726738>", inline=True)
embed.add_field(name=".", value="```yaml\n \t\t\t\tENDER vs ENDER```")
embed.add_field(name=".", value="A VENIR[]")
channel = bot.get_channel(712559462262767617)
await channel.send_message(embed=embed)
bot.run("TOKEN") ```
Regards,
答案 0 :(得分:0)
channel = bot.get_channel('712559462262767617')
到
channel = bot.get_channel(712559462262767617)
send_message
更改为send
await channel.send(embed=embed)
请告诉我这是否可行。 好像您使用的是旧版本的discord.py
我从Trying to send a message to a specific channel using Discord.py rewrite and it isn't working
得到了这个答案答案 1 :(得分:0)
此 API参考可能会更有用:https://discordpy.readthedocs.io/en/latest/api.html#textchannel
您必须使用发送而不是我上面链接的文档中定义的 send_message
embed = discord.Embed(title="Hi!")
channel = bot.get_channel(712559462262767617)
await channel.send(embed=embed)
discord.py的新版本中,您需要了解一些更改。
例如,
send_message
成为send
请随时检查此链接以获取完整的更改列表: https://discordpy.readthedocs.io/en/latest/migrating.html