我希望我的机器人每5分钟编辑一条消息。
例如
msg = discord.utils.get(message, "edited")
cliend.edit_message(message, msg)
答案 0 :(得分:0)
你的意思是这样吗?
bot=commands.Bot(command_prefix='.')
messages=[]
async def edit_msg():
num=0
while True:
if messages:
for i in messages:
await bot.edit_message(i,new_content=f'This is message {num}')
num+=1
await asyncio.sleep(300)
@bot.event
async def on_ready():
await edit_msg()
print(f"{bot.user.name} is ready to run!")
@bot.command(pass_context=True)
async def edit_me(con,*,message):
msg=await bot.say(message)
messages.append(msg)
@bot.command(pass_context=True)
async def edit_emb(msg):
emb=discord.Embed(title='Title Embed')
emb.add_field(name='name of the embed',value='value for field')
reply=await bot.say(embed=emb)
await asyncio.sleep(3)
new_embed=discord.Embed(title='New embed')
new_embed.add_field(name='new emb',value='the new value')
await bot.edit_message(reply,embed=new_embed)