public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services) { if (context.Guild.Id != Program.TheGrandCodingGuild.Id) { return(Task.FromResult(PreconditionResult.FromError($"User is not within the {Program.TheGrandCodingGuild.Name} guild"))); } var self = FourAcesCasino.GetTGCUser(context.User as SocketGuildUser); if (self.Blocked_Toggle_By != 0) { return(Task.FromResult(PreconditionResult.FromError($"You are prevented from changing your own roles\r\nYou may wish to contact any Admin. (ref code {self.Blocked_Toggle_By})"))); } return(Task.FromResult(PreconditionResult.FromSuccess())); }
public async Task PreventToggleRoles(SocketGuildUser target) { var user = FourAcesCasino.GetTGCUser(target); if (user.Blocked_Toggle_By != 0) { user.Blocked_Toggle_By = 0; await ReplyAsync("Removed mark that prevented them toggling the role."); } else { user.Blocked_Toggle_By = Context.User.Id; await ReplyAsync("Added a mark preventing them from changing their roles.\r\nIf they have the Discord permission (or admin perms) they can bypass this"); } }
public async Task PreventNicknameChange(SocketGuildUser target) { TGCUser user = FourAcesCasino.GetTGCUser(target); if (user.Blocked_Nickname_By != 0) { user.Blocked_Nickname_By = 0; await ReplyAsync("Removed the mark preventing that user from changing their nickname"); } else { user.Blocked_Nickname_By = Context.User.Id; await ReplyAsync("User has been marked as unable to change their nickname\nNote that if they have the Discord permission (or have admin perms) they can set it anyway"); } }
protected override void BeforeExecute(CommandInfo command) { var usr = TheGrandCodingGuild.GetUser(Context.User.Id); var tgcUser = FourAcesCasino.GetTGCUser(usr); Self = tgcUser; if (Self.User.Guild.Id != TheGrandCodingGuild.Id) { LogMsg("Invalid guild for Self TGC user " + Self.User.Guild.Name); Self.User = TheGrandCodingGuild.GetUser(Self.User.Id); } if (command.Name.StartsWith("toggle ")) { if (Self.Blocked_Toggle_By != 0) { } } base.BeforeExecute(command); }
public async Task CheckForEnd() { if (Impeachment != null) { if (Impeachment.TargetIndicted) { if (Impeachment.TargetRemoved) { await Impeachment.SentMessage.Channel.SendMessageAsync($"{Impeachment.Target.Name} has been impeached and removed!"); foreach (var div in Impeachment.RemovingFrom) { div.Employees.RemoveAll(x => x.Id == Impeachment.Target.User.Id); if (div.DivisionHead.Id == Impeachment.Target.User.Id) { if (div.Employees.Count > 0) { div.DivisionHead = div.Employees.FirstOrDefault(); await div.DivisionHead.AddRoleAsync(div.DivisionHeadRole); await div.DivisionStaffChannel.SendMessageAsync($"Division Head was impeached and {div.DivisionHead.Username} has been promoted"); } else { div.DivisionHead = FourAcesCasino.GetMember("Four Aces Casino").User; await div.DivisionStaffChannel.SendMessageAsync($"Division Head was impeached\r\nDivision currently has no employees at all."); } } else { await div.DivisionStaffChannel.SendMessageAsync($"{Impeachment.Target.Name} was impeached for {Impeachment.Reason}\r\nThey ***must not*** be re-hired"); } } await Program.C_LOGS_FAC_DIVISION.SendMessageAsync("Logging impeachment vote that passed successfully", false, Impeachment.ToEmbed()); Impeachment = null; FourAcesCasino.Save(); } } } }
protected override void AfterExecute(CommandInfo command) { FourAcesCasino.Save(); bool hasAnyOfTheToggleAble = false; SocketGuildUser g = (SocketGuildUser)Context.User; foreach (var role in new IRole[] { Marvel, Tester, Developer, Sports }) { if (g.Roles.Contains(role)) { hasAnyOfTheToggleAble = true; break; } } if (hasAnyOfTheToggleAble) { g.AddRoleAsync(Seperator); } else { g.RemoveRoleAsync(Seperator); } }