示例#1
0
        private async Task FindAndToggleMutedRoleAsync(SocketGuildUser user, SocketGuild guild, bool set)
        {
            await guild.SyncGuildAsync();

            var mutedRole = guild.FindMutedRole();

            if (mutedRole == null)
            {
                return; // Mute role not exists on this server.
            }
            if (set)
            {
                await user.SetRoleAsync(mutedRole);
            }
            else
            {
                await user.RemoveRoleAsync(mutedRole);
            }
        }