【发布时间】:2020-12-01 19:10:13
【问题描述】:
我正在尝试让机器人识别用户何时输入,如果该用户是我,它会发送一条消息。我不知道我是否用错了,但我阅读了 API,但对我来说仍然没有意义。该机器人没有响应我在我的不和谐测试服务器的默认聊天中所做的任何输入。我尝试简化它以确保它实际上没有看到我的打字并且它仍然不起作用,任何想法。代码如下。
import discord
from discord.ext import commands
token = ('~my token~')
client = commands.Bot(command_prefix = '.')
client.case_insensitive = (True)
@client.event
async def on_ready():
print('Ready')
@client.event
async def on_member_join(user):
print(f'~Temp~ {user} joined the server.')
@client.event
async def on_guild_join(server):
print(f'~Temp~ {server} joined')
@client.event
async def on_typing(channel, user, when):
print('Ready')
'''
if user.id == id1:
await channel.send('1')
elif user.id == id2:
await channel.send('2')
else:
await channel.send('3')
'''
@client.event
async def on_message(message):
print('~Temp~ Message found')
client.run(token)
【问题讨论】:
-
您可能需要将
Intents.typing设置为True
标签: discord.py