给用户角色DSharpPlus

时间:2018-11-25 23:59:43

标签: c# discord

在以下代码中,我需要替换IGuildUser。 (我在DSharpPlus中进行编码:https://github.com/DSharpPlus/DSharpPlus):

    [Command("i_accept"), Description("Accept the rules and gain full access to the server.")]
    [Hidden]
    public async Task accept(CommandContext ctx)
    {
        var user = ctx.User;
        var role = ctx.Guild.Roles.FirstOrDefault(x => x.Name == "Approved");
        await (user as IGuildUser).AddRoleAsync(role);
        await ctx.RespondAsync("You are now approved!");
    }

1 个答案:

答案 0 :(得分:0)

您将角色添加到公会中的成员,方法是首先获取<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <table> <tr> <td title="td_title_1" value="td_value_1">Some text<a href="#" title="Copy">Element_1</a></td> <td title="td_title_2" value="td_value_2">Some other text<a href="#" title="Copy">Element_2</a></td> </tr> </table>实例,然后添加角色。

DiscordMember

请注意,这仅在行会中有效,并且会在DM中引起问题。