Getting a discord bot to mention other users

后端 未结 2 1007
我寻月下人不归
我寻月下人不归 2021-01-25 07:02

I am working on a bot to do some simple commands for my discord server and I haven\'t been able to figure out how to get the bot to mention people who aren\'t the author.

<
2条回答
  •  抹茶落季
    2021-01-25 07:35

    It looks like you're trying to implement commands without actually using commands. Don't put everything in the on_message event. If you're not sure how to use the discord.ext.commands module, you can look at the documentation for the experimental rewrite branch.

    import discord
    from discord.ext.commands import Bot
    
    bot = Bot(command_prefix='+')
    
    @bot.command()
    async def prank(target: discord.Member):
        await bot.say(target.mention + ' mention')
    
    bot.run('token')
    

    You would use this command with +prank Johnny. The bot would then respond in the same channel @Johnny mention

提交回复
热议问题