本文介紹了Discord.py - 使用特定消息回復 DM的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
試圖讓我的機器人用這是一個 dm"回復 DM;但沒有運氣,這是我的代碼:
trying to make my bot reply to DMs with "this is a dm" but no luck, here's my code:
@client.event
async def on_message(message):
if message.guild == null:
await message.channel.send('this is a dm')
else:
pass
我也試過用這個:
@client.event
async def on_message(message):
if isinstance(message.channel, discord.channel.DMChannel):
await ctx.send('This is a DM')
在最后一個上,由于上??下文 (ctx) 我收到一個錯誤
On that last one, I get an error due to context (ctx)
推薦答案
您發送的第一個代碼使用了 null
,這在 python 中甚至都不是.第二個有點不必要,改用這個:
The first code you sent uses null
which isn’t even a thing in python. The second one is a bit unnecessary, use this instead:
@client.event
async def on_message(message):
if not message.guild:
await message.channel.send('this is a dm')
這篇關于Discord.py - 使用特定消息回復 DM的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!