本文介紹了在消息刪除消息 Discord.py的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
import discord
import asyncio
client = discord.Client()
@client.event
async def on_ready():
print ("I’m Now Online")
@client.event
async def on_message(message):
if message.author == client.user:
return
elif message.content.startswith("deletethis"):
我想知道當(dāng)消息的作者發(fā)送上面的命令時(shí),我怎么能添加到這個(gè)來(lái)刪除上面的命令.有人可以幫助創(chuàng)建一個(gè)嗎?我已經(jīng)嘗試了自己的大腦并沒(méi)有在網(wǎng)上找到任何東西,所以我正在尋求一些幫助.
I’m wonder how I could be able to add to this to delete the above command when the author of the message sends the command above. May someone help create one? I’ve tried my self by brain and didn’t find anything online so I’m looking for some help maybe.
推薦答案
for 異步只做
await client.delete_message(message)
否則 重寫(xiě)就可以了p>
otherwise for rewrite just do
await message.delete()
完成的代碼:
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith("deletethis"):
await asyncio.sleep(1)
await message.delete()
這篇關(guān)于在消息刪除消息 Discord.py的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!