Python Discord.py帮助如何检测消息是否由特定用户id发送

Python Discord.py帮助如何检测消息是否由特定用户id发送,python,python-3.x,discord.py,Python,Python 3.x,Discord.py,现在我正试着让我的机器人检查我,只有我写了一条信息,上面写着文字。但是我不知道如何使discordpy,看看我是否发送了消息,我假设我必须使用message.author.id()方法。请帮忙三, #MODULES import discord from discord.ext import commands from discord.utils import get #THE CODE bot = commands.Bot(command_prefix = '.') @bot.even

现在我正试着让我的机器人检查我,只有我写了一条信息,上面写着文字。但是我不知道如何使discordpy,看看我是否发送了消息,我假设我必须使用message.author.id()方法。请帮忙三,

#MODULES

import discord
from discord.ext import commands
from discord.utils import get

#THE CODE

bot = commands.Bot(command_prefix = '.')

@bot.event
async def on_message(message):
    if message.author == bot.user:
        return

    if message.author.id('MY ACTUAL USER ID'):
        await bot.say('words')


bot.run('MY BOT TOKEN')

bot.say
已从旧异步分支中弃用。不管是哪种方式,您还没有定义它将消息发送到哪里。确保您的用户id没有使用字符串,它是一个int,可以不带引号地传递

只需更换123。。。用你或别人的身份证

if message.author.id('我的实际用户id'):
应该改为
if message.author.id==123456789:

@bot.event
async def on_message(message):
    if message.author == bot.user:
        return

    if message.author.id == 123456789:
        await message.channel.send('words')

bot.say
已从旧异步分支中弃用。不管是哪种方式,您还没有定义它将消息发送到哪里。确保您的用户id没有使用字符串,它是一个int,可以不带引号地传递

只需更换123。。。用你或别人的身份证

if message.author.id('我的实际用户id'):
应该改为
if message.author.id==123456789:

@bot.event
async def on_message(message):
    if message.author == bot.user:
        return

    if message.author.id == 123456789:
        await message.channel.send('words')

如果它对你有帮助,请记住将其标记为正确。如果它对你有帮助,请记住将其标记为正确