public async Task AddRank([Summary("Name of the rank to add")][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 (role.Position > Context.Guild.CurrentUser.Hierarchy) { await ReplyAsync("That role has a higher postion than that bot!"); return; } if (ranks.Any(x => x.Id == role.Id)) { await ReplyAsync("That role is already a rank!"); return; } await _rankService.AddRank(Context.Guild.Id, role.Id); //await ReplyAsync($"The role {role.Mention} had been added to the ranks!"); await Context.Channel.SendEmbedAsync("Rank added", $"The role {role.Mention} had been added to the ranks!", await _servers.GetEmbedColor(Context.Guild.Id)); await _servers.SendLogsAsync(Context.Guild, "Rank Added", $"{Context.User.Mention} added {role.Mention} to the ranks!"); _logger.LogInformation("{user} added {role} to the ranks for {server}", Context.User.Username, role.Name, Context.Guild.Name); }
public IActionResult CreateRank(ProjectRankModel model) { ViewBag.IsLogin = !string.IsNullOrEmpty(cache.GetString("user")); if (ViewBag.IsLogin) { ViewBag.User = JsonConvert.DeserializeObject <AccountModel>(cache.GetString("user")); } else { return(RedirectToAction("Login", "Account")); } if (!ViewBag.User.IsAdmin) { return(RedirectToAction("Login", "Account")); } if (ModelState.IsValid) { ranksvc.AddRank(model); return(RedirectToAction(nameof(ProjectSystem))); } return(View(model)); }