I want to edit a embed in on_ready event this is the only way i can edit can do on_message or is there a way to keep a function running until the program ends?
from discord.ext import commands
import discord
from discord.utils import get
@bot.event
async def on_ready():
msg = bot.get_message(892788147287654471)
em = discord.Embed(title="lik",description="kjk")
await msg.edit(embed=em)
bot.run(os.environ['token'])
error code:
Ignoring exception in on_ready
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 56, in on_ready
msg = bot.get_message(892788147287654471)
AttributeError: 'Bot' object has no attribute 'get_message'
CodePudding user response:
Well as the error says, bot has no get_message
attribute. Instead what you can do is get the channel, and then get the message or partial message within.
https://discordpy.readthedocs.io/en/master/api.html?highlight=partial message#discord.PartialMessage
Example:
message = bot.get_channel(1234567890).get_partial_message(1234567890)
await message.edit(content="test")