【问题标题】:Trying to get discord bot to respond when certain person starts typing试图让不和谐机器人在某些人开始打字时做出响应
【发布时间】:2020-12-01 02:25:48
【问题描述】:

我需要帮助的部分在底部 任何建议和帮助将不胜感激。 以下是全部代码:

 #Get Discord
import discord
# Client
client= discord.Client()


@client.event
async def on_ready():
# Commands
 testing_channel = client.get_channel(781417659019034634)
 await testing_channel.send ('Ready')

@client.event
async def on_message(message):
    if message.content == 'why is corey sad':
      testing_channel = client.get_channel(781417659019034634)
      await testing_channel.send ('Because julia got a bf 0.2 secs after breaking up with him') 


@client.event
async def on_typing(channel, user, when):
    if user.id == 574638576155754498: 
        testing_channel = client.get_channel(781417659019034634)
        await testing_channel.send('Why')

【问题讨论】:

  • 有什么问题?
  • 也尽快删除您的令牌并更改它!!!!!!!有人可以控制你的机器人
  • 我现在就去做!而且每当有人键入它时,它就不会说该消息。

标签: discord.py


【解决方案1】:

所以基本上,你忘了启用意图

intents = discord.Intents.default()
intents.members = True

client = discord.Client(intents=intents)

我已启用成员意图,因此 user 变量在 on_typing 事件中不是 None, 还可以在developer portal 中启用特权成员意图

Here'sintents介绍

【讨论】:

  • 非常感谢!
  • 如果有帮助记得采纳答案
  • 哈哈哈抱歉不知道你能做到,只是做到了。再次感谢。
猜你喜欢
  • 2020-12-30
  • 1970-01-01
  • 2020-10-03
  • 1970-01-01
  • 2020-09-27
  • 2021-07-07
  • 2018-11-25
  • 1970-01-01
  • 2020-09-03
相关资源
最近更新 更多