【问题标题】:on_typing not responding to typing discord.pyon_typing 没有响应输入 discord.py
【发布时间】: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)

【问题讨论】:

标签: discord.py


【解决方案1】:

您需要启用意图才能工作

intents = discord.Intents.default()
client = commands.Bot(.., intents=intents)

A Primer to Gateway Intents

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-05-08
    • 1970-01-01
    • 2021-06-07
    • 2021-08-18
    • 2021-11-03
    • 1970-01-01
    • 2021-04-01
    相关资源
    最近更新 更多