public async Task RefreshGuildChangesAsync() { foreach (BlackListedChannel blc in this.Settings.BlackListChannels) { SocketGuildChannel channel = Global.Kuro.Client.GetChannel(blc.Id) as SocketGuildChannel; if (channel != null) { if (blc.Channel != channel.Name) { blc.Channel = channel.Name; } if (blc.Guild != channel.Guild.Name) { blc.Guild = channel.Guild.Name; } } else { this.Settings.BlackListChannels.Remove(blc); } } foreach (AdminUser admin in this.Settings.Admins) { SocketUser user = Global.Kuro.Client.GetUser(admin.Id); if (user.Username != admin.Username) { admin.Username = user.Username; } } foreach (GreetMessage msg in this.Settings.GreetMessages) { SocketGuildChannel channel = Global.Kuro.Client.GetChannel(msg.ChannelID) as SocketGuildChannel; if (channel != null) { if (channel.Name != msg.ChannelName) { msg.ChannelName = channel.Name; } if (channel.Guild.Name != msg.GuildName) { msg.GuildName = channel.Guild.Name; } } else { this.Settings.GreetMessages.Remove(msg); } } this.SaveSettings(); await ControlHandler.ShowSettingsValueAsync(); }
public async static Task <bool> RemoveBlackList(SocketTextChannel Channel) { if (Global.SettingsHandler.Settings.BlackListChannels.FindIndex(u => u.Id == Channel.Id) > -1) { Global.SettingsHandler.Settings.BlackListChannels.Remove(Global.SettingsHandler.Settings.BlackListChannels.Find(u => u.Id == Channel.Id)); await ControlHandler.LogAsync("[PERMHANLDER] Blacklisted channel has been Removed: " + Channel.Id); Global.SettingsHandler.SaveSettings(); await ControlHandler.ShowSettingsValueAsync(); return(true); } else { return(false); } }
//Admin stuff public async static Task <bool> AddAdmin(string Username, ulong UserID, string Addedby) { if (Global.SettingsHandler.Settings.Admins.FindIndex(u => u.Id == UserID) == -1) { Global.SettingsHandler.Settings.Admins.Add(new AdminUser(Username, UserID, Addedby)); await ControlHandler.LogAsync("[PERMHANLDER] An admin has been added: " + Username); Global.SettingsHandler.SaveSettings(); await ControlHandler.ShowSettingsValueAsync(); return(true); } else { return(false); } }
//Blacklist stuff public async static Task <bool> AddBlackList(SocketTextChannel Channel, string AddedBy) { if (Global.SettingsHandler.Settings.BlackListChannels.FindIndex(u => u.Id == Channel.Id) == -1) { Global.SettingsHandler.Settings.BlackListChannels.Add(new BlackListedChannel(Channel.Guild.Name, Channel.Id, Channel.Name, AddedBy)); await ControlHandler.LogAsync("[PERMHANLDER] Blacklisted channel has been Added: " + Channel.Id); Global.SettingsHandler.SaveSettings(); await ControlHandler.ShowSettingsValueAsync(); return(true); } else { return(false); } }
public async static Task <bool> RemoveAdmin(ulong UserID) { if (Global.SettingsHandler.Settings.Admins.FindIndex(u => u.Id == UserID) == -1) { AdminUser OldAdmin = Global.SettingsHandler.Settings.Admins.Find(u => u.Id == UserID); await ControlHandler.LogAsync("[PERMHANLDER] An admin has been Removed: " + OldAdmin.Username); Global.SettingsHandler.Settings.Admins.Remove(Global.SettingsHandler.Settings.Admins.Find(u => u.Id == UserID)); Global.SettingsHandler.SaveSettings(); await ControlHandler.ShowSettingsValueAsync(); return(true); } else { return(false); } }