【问题标题】:Discord.py - Finding information about the senderDiscord.py - 查找有关发件人的信息
【发布时间】:2017-12-22 20:13:19
【问题描述】:

我正在制作一个简单的不和谐机器人,并试图找出消息的渠道和发件人,例如,当某些人输入d!salute blah 时,它会回复"<SENDER> saluted blah!",并附上一张图片。我目前只知道如何使用client.say,它为我找到了频道。我想知道的是如何检索发送消息的通道以及命令的发送者。谢谢

【问题讨论】:

    标签: python bots discord discord.py


    【解决方案1】:

    您需要传递上下文以便访问消息对象。

    @client.command(pass_context = True) #passing context
    async def salute(ctx): #context gets passed into the first parameter
        print(str(ctx.message.author))
        print(str(ctx.message.channel)
        print(str(ctx.message.content))
    

    等等,你可以在The docs找到更多关于消息对象的信息

    【讨论】:

    • 你能告诉我如何找到发送消息的人的角色吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-05
    • 1970-01-01
    • 1970-01-01
    • 2011-03-21
    • 1970-01-01
    • 2018-04-10
    相关资源
    最近更新 更多