【问题标题】:Discord bot, how do I assign a role to the user you mentioned?Discord bot,我如何为您提到的用户分配角色?
【发布时间】:2020-07-07 09:30:34
【问题描述】:

是的,我都是通过客户端完成的,但我不需要输入命令,我只是想进行一个小游戏“僵尸”,其中用户ping其他用户将他们变成僵尸。为此,机器人必须为在消息中被此人 ping 的人赋予特定角色。我得到了您正在 ping 的人的 ID(也许这会有所帮助)。提前致谢。

代码在这里:

import discord
from discord import utils


client = discord.Client()

@client.event
async def on_ready():
    print('Connected')


@client.event

async def on_message(message):
    if message.author == client.user:
        return
    role = discord.utils.get(message.guild.roles, name='Hot pink') # i get role
    user = message.mentions[0].id #i get id of mention people
  # await .add_roles(mute_role) PROBLEM IS HERE (me need, to give role, to mentioned people)

【问题讨论】:

  • 到目前为止你尝试了什么?

标签: python discord roles member


【解决方案1】:

我不明白这段代码来自哪里?这是在你的主 js 文件中吗?

你试过了吗?

var role = message.guild.roles.find(role => role.name === "MyRole"); message.member.addRole(角色);

【讨论】:

    猜你喜欢
    • 2020-09-07
    • 2021-03-13
    • 2019-11-01
    • 2020-07-13
    • 2020-09-02
    • 1970-01-01
    • 1970-01-01
    • 2022-01-09
    • 2021-04-15
    相关资源
    最近更新 更多