本文介紹了Discord.py 使用 wait_for 檢查用戶輸入的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我正在嘗試創建一個日志設置命令,例如:消息編輯日志會打開嗎?"如果是:發送頻道 ID.我試圖創建的命令與此類似.我的代碼是這樣的.我是 discord.py 的菜鳥.這是代碼,感謝您的幫助.
I am trying to create a log setup command like: "Are message edit logs going to be on?" if yes: send the channel id. The command im trying to create is something similar to this. My code is this. I'm a noob in discord.py. Here is the code and thanks for the help.
注意:執行命令時我沒有得到任何輸出.
Note: I don't get any output when the command is executed.
@bot.command(name="logsetup")
@commands.guild_only()
@commands.has_any_role("Head Admininstaror", "Adminstaror", "Owner")
async def log_setup(self, ctx):
await ctx.send("Message edit logs: On/Off")
msg = await bot.wait_for('message', check=lambda message: message.author == ctx.author)
if msg.content.lower() == "on":
print("Working.")
await ctx.send("Send the channel ID.")
msg = await bot.wait_for('message', check=lambda message: message.author == ctx.author)
editedMessageChannel = msg.content
ctx.send("Channel is set.")
推薦答案
我在@Kelo 的幫助下發現了問題.感謝他/她,我發現我忘記添加自我了.
I found the problem with the help of @Kelo. Thanks to him/her, I found out that i forgot to add self.
這篇關于Discord.py 使用 wait_for 檢查用戶輸入的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!