【问题标题】: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')