コード例 #1
0
    public async Task RemoveAsync(SocketUserMessage message, IRole role)
    {
        var componentBuilder = new ComponentBuilder();

        // Rebuild components without the role.
        IList <ActionRowBuilder> rows = message.Components
                                        .Select(row => row.Components
                                                .Where(component =>
                                                       component.CustomId != $"{Prefix}-{message.Id}-{role.Id}").ToList())
                                        .Where(components =>
                                               components.Count > 0)
                                        .Select(components =>
                                                new ActionRowBuilder().WithComponents(components))
                                        .ToList();

        componentBuilder.WithRows(rows);
        await message.ModifyAsync(properties => properties.Components = componentBuilder.Build());

        await RespondAsync($"Removed role {role.Mention} to message: **{message.Id.ToString()}**.", ephemeral : true);
    }