最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

每 15 分鐘發(fā)送一條關(guān)于 Discord 的消息

每 15 分鐘發(fā)送一條關(guān)于 Discord 的消息

慕妹3242003 2023-10-25 10:44:54
我正在嘗試制作一個(gè)每 15 分鐘發(fā)送一條隨機(jī)消息的機(jī)器人。機(jī)器人加載沒有問題,但沒有發(fā)送消息,我是否遺漏了什么?import discordimport asyncioimport randomfrom discord.ext import commands, tasksclient = discord.Client()token = 'xxx'@tasks.loop(seconds=5)async def background_loop():    await client.wait_until_ready()    while not client.is_closed:        channel = client.get_channel(xxx)        messages = ["Hello!", "How are you doing?", "Howdy!"]        await channel.send(random.choice(messages))background_loop.start()@client.eventasync def on_ready():    print('Logged in as')    print(client.user.name)    print(client.user.id)    print('------')client.run(token)
查看完整描述

1 回答

?
Qyouu

TA貢獻(xiàn)1786條經(jīng)驗(yàn) 獲得超11個(gè)贊

如果您嘗試使用tasks,那么您的使用方式就有點(diǎn)錯(cuò)誤了。這是有關(guān)如何使用的文檔tasks。另外,沒有什么像client.send_message.?你可以這樣做channel.send(message)。

@tasks.loop(minutes=15.0)

async def background_loop():

? ? await client.wait_until_ready()

? ? while not client.is_closed:

? ? ? ? channel = client.get_channel(id)

? ? ? ? messages = ["Hello!", "How are you doing?", "Howdy!"]

? ? ? ? await channel.send(random.choice(messages))

background_loop.start()


查看完整回答
反對(duì) 回復(fù) 2023-10-25
  • 1 回答
  • 0 關(guān)注
  • 112 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)