【问题标题】:Bot replying to a message from a specific user - Discord.py机器人回复来自特定用户的消息 - Discord.py
【发布时间】:2021-04-20 03:55:22
【问题描述】:

只有特定的用户和特定的词才能让机器人输入

example:
THE SPECIFIC USER : User1
THE SPECIFIC WORD : PASSCODE
-----------------------
User1: Hello (didn't input)
User2: PASSCODE (didn't input)
User1: PASSCODE (input)
BOT  : RESPOND

【问题讨论】:

    标签: python discord bots discord.py


    【解决方案1】:

    请记住,ID 不能介于“...”、“...”之间 只是数字!

    例子:

    if message.author.id == 000000000000000000 and message.content.upper() == 'PASSCODE':
        await message.channel.send('RESPOND')
    

    【讨论】:

      【解决方案2】:

      加入我们的 discord 服务器,帮助我们创建 discord.py 机器人! https://discord.gg/Nte4DseR

      import discord
      
      from discord.ext import commands
      
      client = commands.Bot(command_prefix='YOUR PREFIX')
      
      guild = client.get_guild('GUILD ID')
      
      @client.event
      async def on_message(message):
      
          user = client.get_user('MEMBER ID')
      
          if message.author == client.user:
      
              return
      
          if message.author == user:
      
              if message.content == 'PASSCODE':
      
                  await message.channel.send('RESPOND')
      
      client.run('SERVER ID')
      

      【讨论】:

      • 我对你的消息投了赞成票,认为这可以在未来使用
      猜你喜欢
      • 2023-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-27
      • 2020-08-17
      • 2021-11-28
      • 2020-11-10
      • 2020-07-28
      相关资源
      最近更新 更多