How do I mention a user using user's id in discord.py?

后端 未结 6 675
名媛妹妹
名媛妹妹 2020-12-20 13:36

I\'m trying to code a simple bot using discord.py so i started with the fun commands like just to get the hang of the api

import discord
import asyncio
clien         


        
6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-20 14:20

    If you just want to respond from the on_message callback, you can grab the mention string from the author like so:

    @bot.event
    async def on_message(message):
        # No infinite bot loops
        if message.author == bot.user or message.author.bot:
            return
    
        mention = message.author.mention
        response = f"hey {mention}, you're great!"
        await message.channel.send(response)
    

提交回复
热议问题