Getting a discord bot to mention other users

后端 未结 2 1008
我寻月下人不归
我寻月下人不归 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条回答
  •  梦毁少年i
    2021-01-25 07:24

    The specific error you are getting is caused by not awaiting a coroutine. client.get_user_info is a coroutine and must use await.

    If you want "+prank" to work by mentioning by username, you can find a member object by using server.get_member_named.

    Example code provided below. This will check the server the command was called from for the specified username and return the member object.

    if message.content.startswith("+prank"):
        username = message.content[7:]
        member_object = message.server.get_member_named(username)
        await client.send_message(message.channel, member_object.mention + 'mention')
    

提交回复
热议问题