机器人回复来自特定用户的消息 - Discord.py

时间:2021-01-15 04:51:52

标签: python discord bots discord.py

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

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

2 个答案:

答案 0 :(得分:1)

加入我们的 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')

答案 1 :(得分:0)

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

示例:

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