public async Task DeWhitenUserCommand([Remainder] SocketGuildUser u = null) { u = u ?? (SocketGuildUser)Context.User; var caller = _db.FirstOrDefault <WhitelistUser>(Defined.WHITELIST_TABLE_NAME, (x => x.Id == Context.User.Id)); var target = _db.FirstOrDefault <WhitelistUser>(Defined.WHITELIST_TABLE_NAME, (x => x.Id == u.Id)); if (caller != null) { if (target != null) { if (target.Id == caller.Id || caller.IsOwner) { _db.DeleteEntity <WhitelistUser>(Defined.WHITELIST_TABLE_NAME, (x => x.Id == u.Id)); Defined.BuildSuccessMessage(_eBuilder, Context, $"Successfully removed the User **{u.Username}#{u.Discriminator}** from the Whitelist"); } else { Defined.BuildErrorMessage(_eBuilder, Context, ErrorTypes.E410, null, "remove a User who isn't yourself from the Whitelist"); } } else { Defined.BuildErrorMessage(_eBuilder, Context, ErrorTypes.E404, $"{u.Username}#{u.Discriminator}", "User", "the Whitelist"); } } else { Defined.BuildErrorMessage(_eBuilder, Context, ErrorTypes.E409, null, "remove a User from the Whitelist"); } await ReplyAsync(embed : _eBuilder.Build()); }
public async Task WhitenUserCommand([Remainder] SocketGuildUser u = null) { u = u ?? (SocketGuildUser)Context.User; if (u.IsBot) { Defined.BuildErrorMessage(_eBuilder, Context, ErrorTypes.E411, null, "added to the Whitelist"); } else { if (_db.Exists <WhitelistUser>(Defined.WHITELIST_TABLE_NAME, (x => x.Id == Context.User.Id))) { if (!_db.Exists <WhitelistUser>(Defined.WHITELIST_TABLE_NAME, (x => x.Id == u.Id))) { _db.AddEntity(Defined.WHITELIST_TABLE_NAME, new WhitelistUser(u.Id, _db.IsEmpty <WhitelistUser>((Defined.WHITELIST_TABLE_NAME)))); if (_db.Exists <BlacklistUser>(Defined.BLACKLIST_TABLE_NAME, (x => x.Id == Context.User.Id))) { _db.DeleteEntity <BlacklistUser>(Defined.BLACKLIST_TABLE_NAME, (x => x.Id == Context.User.Id)); } } Defined.BuildSuccessMessage(_eBuilder, Context, $"Successfully added the User **{u.Username}#{u.Discriminator}** to the Whitelist"); } else { Defined.BuildErrorMessage(_eBuilder, Context, ErrorTypes.E410, null, "add a User to the Whitelist"); } } await ReplyAsync(embed : _eBuilder.Build()); }
public async Task ChangeOwnerCommand([Remainder] SocketGuildUser u = null) { u = u ?? (SocketGuildUser)Context.User; var whitelist = _db.GetCollection <WhitelistUser>(Defined.WHITELIST_TABLE_NAME).FindAll(); if (whitelist.FirstOrDefault(x => x.IsOwner) == null) { var tUser = whitelist.FirstOrDefault(x => x.Id == u.Id); if (tUser == null) { tUser = new WhitelistUser(u.Id, true); _db.GetCollection <WhitelistUser>(Defined.WHITELIST_TABLE_NAME).Insert(tUser); } else { tUser.IsOwner = true; _db.GetCollection <WhitelistUser>(Defined.WHITELIST_TABLE_NAME).Update(tUser); } } else if (whitelist.FirstOrDefault(x => x.IsOwner).Id == Context.User.Id) { if (u.Id != Context.User.Id) { var currUser = whitelist.FirstOrDefault(x => x.Id == Context.User.Id); currUser.IsOwner = false; var tUser = whitelist.FirstOrDefault(x => x.Id == u.Id); if (tUser == null) { tUser = new WhitelistUser(u.Id, true); _db.GetCollection <WhitelistUser>(Defined.WHITELIST_TABLE_NAME).Insert(tUser); } else { tUser.IsOwner = true; _db.GetCollection <WhitelistUser>(Defined.WHITELIST_TABLE_NAME).Update(tUser); } _db.GetCollection <WhitelistUser>(Defined.WHITELIST_TABLE_NAME).Update(currUser); } Defined.BuildSuccessMessage(_eBuilder, Context, $"Successfully changed the Owner of {_config.Bot_Name}"); } else { Defined.BuildErrorMessage(_eBuilder, Context, ErrorTypes.E410, null, "change the Owner"); } await ReplyAsync(embed : _eBuilder.Build()); }
public async Task DeleteEmoteNicknameCommand([Remainder] string nick) { nick = nick.Replace(":", string.Empty).ToLower(); EeveeEmote emote = _db.TryEmoteAssociation(Context.User.Id, nick); if (emote != null) { emote.Aliases.RemoveAll(x => x.Alias.ToLower() == nick); _db.UpdateEntity(Defined.EEVEE_EMOTES_TABLE_NAME, emote); Defined.BuildSuccessMessage(_eBuilder, Context, $"Deleted the Nickname **{nick}** from the Emote {emote}."); } else { Defined.BuildErrorMessage(_eBuilder, Context, ErrorTypes.E404, nick, "Alias", "the Emote Database"); } await ReplyAsync(string.Empty, embed : _eBuilder.Build()); }
public void AddAliasEmote(string nick, EeveeEmote emote, string name, bool overrideinfo = true) { if (nick.Length < Defined.NICKNAME_LENGTH_MIN) { Defined.BuildErrorMessage(_eBuilder, Context, ErrorTypes.E406, Defined.NICKNAME_LENGTH_MIN, "Nickname (Alias)"); } else if (!_db.Exists <EeveeEmote>(Defined.EEVEE_EMOTES_TABLE_NAME, (x => x.Name.ToLower() == nick || x.Aliases.Where(y => y.OwnerId == Context.User.Id).Count(y => y.Alias == nick) > 0))) { if (emote != null) { if (emote.Aliases.Count(x => x.OwnerId == Context.User.Id) > Defined.NICKNAME_COUNT_MAX) { Defined.BuildErrorMessage(_eBuilder, Context, ErrorTypes.E408, null, $"You have exceeded the Aliases capacity limit for this Emote!" + $"\nIf you'd really like to add this one, please use {_config.Prefixes[0] }emotes delnick <nick> on " + $"one of the following:\n{string.Join("\n", emote.Aliases.Where(x => x.OwnerId == Context.User.Id).Select(x => x.Alias))}"); } else { emote.Aliases.Add(new EeveeEmoteAlias() { AssociatedEmoteId = emote.Id, Alias = nick, OwnerId = Context.User.Id }); _db.UpdateEntity(Defined.EEVEE_EMOTES_TABLE_NAME, emote); Defined.BuildSuccessMessage(_eBuilder, Context, $"Added the Alias **{nick}** to the Emote {emote}.", overrideinfo); } } else { Defined.BuildErrorMessage(_eBuilder, Context, ErrorTypes.E404, name, "Emote", "the Emote Database", overrideinfo); } } else { Defined.BuildErrorMessage(_eBuilder, Context, ErrorTypes.E405, name, "Alias or Emote", "the Emote Database", overrideinfo); } }
public async Task DeleteEmoteCommand([Remainder] string name) { if (_db.Exists <WhitelistUser>(Defined.WHITELIST_TABLE_NAME, (x => x.Id == Context.User.Id))) { var emotes = _db.GetWhere <EeveeEmote>(Defined.EEVEE_EMOTES_TABLE_NAME, (x => x.TryAssociation(name, Context.User.Id))); if (emotes.Count() > 0) { string pickMesasge = "Please pick one of the following:\n" + string.Join("\n", emotes.Select(x => $"{emotes.ToList().IndexOf(x)} : {x} \\{x}")); await ReplyAsync(pickMesasge); var emote = emotes.FirstOrDefault(); _db.DeleteEntity <EeveeEmote>(Defined.EEVEE_EMOTES_TABLE_NAME, (x => x.Id == emote.Id)); var guild = Context.Client.GetGuild(emote.GuildId); await guild.DeleteEmoteAsync(await guild.GetEmoteAsync(emote.Id)); if (guild.Emotes.Count(x => x.Id == emote.Id) < 1) { Defined.BuildSuccessMessage(_eBuilder, Context, $"Successfully deleted the Emote **{name}** from Discord and the Database."); await ReplyAsync(string.Empty, embed : _eBuilder.Build()); } } else { Defined.BuildErrorMessage(_eBuilder, Context, ErrorTypes.E404, name, "Emote", "the Emote Database"); } } else { Defined.BuildErrorMessage(_eBuilder, Context, ErrorTypes.E409, null, "delete an Emote from the Database"); } await ReplyAsync(string.Empty, embed : _eBuilder.Build()); }