我正在嘗試制作一個不和諧的機器人,并且我想添加處理諸如 ?help、?creator 等事件的功能。我想在之后的命令中發送一條訊息?不被認可。這是我的代碼:
import os
import discord
client = discord.Client()
unrecogcommand = "I don't recognize this command do **?help** for the list of the available
commands :3"
@client.event
async def on_ready():
print("We have logged in as {0.user}".format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('?'):
if message.content.startswith('?ownerfavOP'):
await message.channel.send("The server Owner really love Kaikai Kitan
https://www.youtube.com/watch?v=i1P-9IspBus :3")
if message.content.startswith('?creator'):
await message.channel.send("PashPash#7668 is the username of the creator and have a yt
channel https://www.youtube.com/channel/UCxJXY07JAsmJBaYf67KKk7Q")
if message.content.startswith('?help'):
await message.channel.send("Command available ```?help``` ```ownerfavOP```")
client.run(os.getenv('TOKEN'))
uj5u.com熱心網友回復:
我會這樣接近你command:
@client.event
async def on_message(message):
if message.author != client.user:
if message.content.startswith('?'):
if message.content.startswith('?ownerfavOP'):
# do something
elif message.content.startswith('?creator'):
# do something
elif message.content.startswith('?help'):
# do something
else:
print("Couldn't found that command.")
請注意,我洗掉了該return陳述句,因為如果message author等于client user.
我希望這對你有幫助,純粹的!
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/324068.html
上一篇:具有多個可選過濾查詢引數的ASP.NETMVCGET請求
下一篇:熊貓在兩個數字之間填充nan
