Exemplo n.º 1
0
        public async Task DelRank([Summary("Name of the rank to delete")][Remainder] string name)
        {
            await Context.Channel.TriggerTypingAsync();

            var ranks = await _rankService.GetRanks(Context.Guild);

            var role = Context.Guild.Roles.FirstOrDefault(x => string.Equals(x.Name, name, StringComparison.CurrentCultureIgnoreCase));

            if (role == null)
            {
                await ReplyAsync("That role does not exist!");

                return;
            }

            if (ranks.All(x => x.Id != role.Id))
            {
                await ReplyAsync("That role is not a rank yet!");

                return;
            }

            await _rankService.RemoveRank(Context.Guild.Id, role.Id);

            //await ReplyAsync($"The role {role.Mention} has been removed from the ranks!");
            await Context.Channel.SendEmbedAsync("Rank Removed", $"The role {role.Mention} had been removed from the ranks!", await _servers.GetEmbedColor(Context.Guild.Id));

            await _servers.SendLogsAsync(Context.Guild, "Rank removed", $"{Context.User.Mention} removed the rank {role.Mention}.");

            _logger.LogInformation("{user} removed {role} from the ranks in {server}",
                                   Context.User.Username, role.Name, Context.Guild.Name);
        }