public async Task EditServerConfiguration(string ServerId, BotGearServerConfiguration newvals) { try { if (String.IsNullOrWhiteSpace(ServerId) != true && await this.ServersConfigurationExists(ServerId) != false && newvals != null) { var x = await this.GetServersConfigurationById(ServerId); if (x != null) { BotGearServerConfiguration newconf = new BotGearServerConfiguration(); newconf.rules = newvals.rules; newconf.rules_channel_name = newvals.rules_channel_name; newconf.ServerId = x.ServerId; newconf.allow_channels_name = newvals.allow_channels_name; newconf.welcome_channel_name = newvals.welcome_channel_name; newconf.welcome_message = newvals.welcome_message; newconf.allow_channels_mentions = newvals.allow_channels_mentions; db.Entry(x).CurrentValues.SetValues(newconf); await db.SaveChangesAsync(); } } } catch (Exception ex) { CommonTools.ErrorReporting(ex); } }
public async Task setWelcome_Message(string Message) { try { if (String.IsNullOrWhiteSpace(Message) != true) { String serverid = Convert.ToString(this.Context.Guild.Id); if (await srvConfmngr.ServersConfigurationExists(serverid) == true) { var conf = await srvConfmngr.GetServersConfigurationById(serverid); conf.welcome_message = Message; await srvConfmngr.EditServerConfiguration(serverid, conf); await ReplyAsync("Settings had been Set"); } else if (await srvConfmngr.ServersConfigurationExists(serverid) == true && await srvmngr.ServerExists(serverid) != true) { var oldconf = await srvConfmngr.GetServersConfigurationById(serverid); oldconf.welcome_message = Message; await srvConfmngr.EditServerConfiguration(serverid, oldconf); await srvmngr.addServer(this.Context.Guild); await ReplyAsync("Settings had been Set"); } else if (await srvConfmngr.ServersConfigurationExists(serverid) != true && await srvmngr.ServerExists(serverid) == true) { BotGearServerConfiguration conf = new BotGearServerConfiguration(); conf.ServerId = serverid; conf.welcome_message = Message; await this.srvConfmngr.AddServerConfiguration(conf); await ReplyAsync("Settings had been Set"); } else { await srvmngr.addServer(this.Context.Guild); BotGearServerConfiguration conf = new BotGearServerConfiguration(); conf.ServerId = serverid; conf.welcome_message = Message; await this.srvConfmngr.AddServerConfiguration(conf); await ReplyAsync("Settings had been Set"); } } } catch (Exception ex) { CommonTools.ErrorReporting(ex); } }
public async Task setAllowedChannelsByMentions(string channels) { try { if (String.IsNullOrWhiteSpace(channels) != true) { String serverid = Convert.ToString(this.Context.Guild.Id); if (await srvConfmngr.ServersConfigurationExists(serverid) == true) { var conf = await srvConfmngr.GetServersConfigurationById(serverid); conf.allow_channels_mentions = channels; await srvConfmngr.EditServerConfiguration(serverid, conf); await ReplyAsync("Channels had been Set"); } else if (await srvConfmngr.ServersConfigurationExists(serverid) == true && await srvmngr.ServerExists(serverid) != true) { var oldconf = await srvConfmngr.GetServersConfigurationById(serverid); oldconf.allow_channels_mentions = channels; await srvConfmngr.EditServerConfiguration(serverid, oldconf); await srvmngr.addServer(this.Context.Guild); await ReplyAsync("Allowed Channels had been Set"); } else if (await srvConfmngr.ServersConfigurationExists(serverid) != true && await srvmngr.ServerExists(serverid) == true) { BotGearServerConfiguration conf = new BotGearServerConfiguration(); conf.ServerId = serverid; conf.allow_channels_mentions = channels; await this.srvConfmngr.AddServerConfiguration(conf); await ReplyAsync("Allowed Channels had been Set"); } else { await srvmngr.addServer(this.Context.Guild); BotGearServerConfiguration conf = new BotGearServerConfiguration(); conf.ServerId = serverid; conf.allow_channels_mentions = channels; await this.srvConfmngr.AddServerConfiguration(conf); await ReplyAsync("Allowed ChannelsChannel had been Set"); } } } catch (Exception ex) { CommonTools.ErrorReporting(ex); } }
public async Task SetRulesChannel(string rulechannelname) { try { if (String.IsNullOrWhiteSpace(rulechannelname) != true) { String serverid = Convert.ToString(this.Context.Guild.Id); if (await srvConfmngr.ServersConfigurationExists(serverid) == true && await srvmngr.ServerExists(serverid) == true) { var oldconf = await srvConfmngr.GetServersConfigurationById(serverid); oldconf.rules_channel_name = rulechannelname; await srvConfmngr.EditServerConfiguration(serverid, oldconf); await ReplyAsync("Rule Channel had been Set"); } else if (await srvConfmngr.ServersConfigurationExists(serverid) == true && await srvmngr.ServerExists(serverid) != true) { var oldconf = await srvConfmngr.GetServersConfigurationById(serverid); oldconf.rules_channel_name = rulechannelname; await srvConfmngr.EditServerConfiguration(serverid, oldconf); await srvmngr.addServer(this.Context.Guild); await ReplyAsync("Rule Channel had been Set"); } else if (await srvConfmngr.ServersConfigurationExists(serverid) != true && await srvmngr.ServerExists(serverid) == true) { BotGearServerConfiguration conf = new BotGearServerConfiguration(); conf.ServerId = serverid; conf.rules_channel_name = rulechannelname; await this.srvConfmngr.AddServerConfiguration(conf); await ReplyAsync("Rule Channel had been Set"); } else { await srvmngr.addServer(this.Context.Guild); BotGearServerConfiguration conf = new BotGearServerConfiguration(); conf.ServerId = serverid; conf.rules_channel_name = rulechannelname; await this.srvConfmngr.AddServerConfiguration(conf); await ReplyAsync("Rule Channel had been Set"); } } } catch (Exception ex) { CommonTools.ErrorReporting(ex); } }
public async Task AddServerConfiguration(BotGearServerConfiguration mod) { try { if (mod != null && await this.ServersConfigurationExists(mod.ServerId) == false) { db.ServerConfiguration.Add(mod); db.SaveChanges(); } } catch (Exception ex) { CommonTools.ErrorReporting(ex); } }
public async Task <BotGearServerConfiguration> GetServersConfigurationById(string servetid) { try { BotGearServerConfiguration ap = null; if (String.IsNullOrWhiteSpace(servetid) != true) { var x = await this.GetAllServerConfiguration(); ap = x.FirstOrDefault(s => s.ServerId == servetid); } return(ap); } catch (Exception ex) { CommonTools.ErrorReporting(ex); return(null); } }