在键入时不响应键入discord.py
我正在尝试让机器人识别用户何时键入,如果该用户是我,它将发送一条消息。我不知道我是否用错了,但我读了API,至少对我来说还是没有意义。bot没有响应我在discord测试服务器的默认聊天中键入的任何内容。我试图简化它,以确保它实际上没有看到我的打字,它仍然无法工作,任何想法。代码如下在键入时不响应键入discord.py,discord.py,Discord.py,我正在尝试让机器人识别用户何时键入,如果该用户是我,它将发送一条消息。我不知道我是否用错了,但我读了API,至少对我来说还是没有意义。bot没有响应我在discord测试服务器的默认聊天中键入的任何内容。我试图简化它,以确保它实际上没有看到我的打字,它仍然无法工作,任何想法。代码如下 import discord from discord.ext import commands token = ('~my token~') client = commands.Bot(command_pref
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=discord.intents.default()
client=commands.Bot(..,intents=intents)
您可能需要设置为True