Python 不一致bot不返回数据
我正忙着构建一个简单的discord机器人,我已经设置了一些基本命令,但只有1个有效。这是Botty.member\u count和Botty.community\u report()下面的代码,没有任何帮助 令牌是*的,原因很明显Python 不一致bot不返回数据,python,discord,discord.py,Python,Discord,Discord.py,我正忙着构建一个简单的discord机器人,我已经设置了一些基本命令,但只有1个有效。这是Botty.member\u count和Botty.community\u report()下面的代码,没有任何帮助 令牌是*的,原因很明显 client = discord.Client() token = '**********************************' @client.event # event decorator/wrapper async def on_ready
client = discord.Client()
token = '**********************************'
@client.event # event decorator/wrapper
async def on_ready():
print(f"We have logged in as {client.user}")
@client.event
async def on_message(message):
print(f"{message.channel}: {message.author}: {message.author.name}: {message.content}")
Botty_guild = client.get_guild(543140047449358338)
if "hello" in message.content.lower():
await message.channel.send("HI!")
if "Botty.member_count" == message.content.lower():
await message.channel.send(f"```{Botty_guild.member_count}```")
elif "Botty.community_report()" == message.content.lower():
online = 0
idle = 0
offline = 0
for m in Botty_guild.members:
if str(m.status) == "online":
online += 1
if str(m.status) == "offline":
offline += 1
else:
idle += 1
await message.channel.send(f"```Online: {online}.\nIdle/busy/dnd: {idle}.\nOffline: {offline}```")
client.run(token)```
“Botty.member\u count”==message.content.lower()
和“Botty.community\u report()”==message.content.lower()
无论什么情况都会返回False
,因此您的if条件不会进入true部分<代码>“Botty.member\u count”。lower()是“Botty.member\u count”