public Adminleave(VirtualServer _server, AdminMessageChannel amc) : base(_server, "adminleave", new HelpMsgStrings("", "adminleave <on/off> <adminleave message>")) { if (amc == null || !amc.sameServer(this.server)) { throw new Exception("setup error"); } server.UserLeft += (s, u) => { if (on && amc.channel != null) { server.safeSendMessage(amc.channel, wmls.Response(u)); } }; }
public Admingreet(VirtualServer _server, AdminMessageChannel amc) : base(_server, "admingreet", new HelpMsgStrings("", "admingreet <on/off> <admingreet message>")) { if (amc == null || !amc.sameServer(this.server)) { throw new Exception("setup error"); } server.UserJoined += (s, u) => { if (on && u.Guild.Id == server.getServer().Id&& amc.channel != null) { server.safeSendMessage(amc.channel, wmls.Response(u)); } }; }
public VirtualServer(DiscordSocketClient _DC, SocketGuild _server) { try { serverpath = _server.Id + "/"; if (!Directory.Exists(serverpath)) { Directory.CreateDirectory(serverpath); } DC = _DC; server = _server; Commandlist = new Dictionary <string, Command>(); var virtualServerCommands = new List <Command>(4); virtualServerCommands.Add(new Command(this, "help", help, PrivilegeLevel.BotAdmin, new HelpMsgStrings("", ""))); //help is very very special virtualServerCommands.Add(new Command(this, "shutdown", shutdown, PrivilegeLevel.BotAdmin, new HelpMsgStrings("", "shutdown <on/off>"))); virtualServerCommands.Add(new Command(this, "addbotadmin", addBotAdmin, PrivilegeLevel.BotAdmin, new HelpMsgStrings("", "addbotadmin <mention-target>"))); virtualServerCommands.Add(new Command(this, "removebotadmin", removeBotAdmin, PrivilegeLevel.BotAdmin, new HelpMsgStrings("", "removebotadmin <mention-target>"))); addCommands(virtualServerCommands); Admins = PersistantList.Create(this, adminfilePath); var adminChannel = new AdminMessageChannel(this); addCommands(adminChannel.getCommands()); addCommands(new Admingreet(this, adminChannel).getCommands()); addCommands(new Adminleave(this, adminChannel).getCommands()); addCommands(new Autogreet(this).getCommands()); var lobbyGreet = new LobbyGreet(this); addCommands(lobbyGreet.getCommands()); addCommands(new Dice(this).getCommands()); addCommands(new Roulette(this).getCommands()); addCommands(new Echo(this).getCommands()); addCommands(new Math(this).getCommands()); addCommands(new Bork(this).getCommands()); addCommands(new KillUserMessages(this).getCommands()); addCommands(new PurgeTheEnclave(this).getCommands()); addCommands(new UntaggedUsers(this).getCommands()); addCommands(new Reminder(this).getCommands()); addCommands(new RunQuery(this).getCommands()); altCommand = new AlternativeCommand(this); addCommands(altCommand.getCommands()); addCommands(new GloriousDirectDemocracy(this).getCommands()); addCommands(new RoleCommand(this, lobbyGreet).getCommands()); addCommands(new StrikeModule(this).getCommands()); addCommands(new EmoteModule(this).getCommands()); addCommands(new ReportModule(this).getCommands()); // addCommands(new Inktober(this).getCommands()); addCommands(new Userinfo(this).getCommands()); addCommands(new Someone(this).getCommands()); addCommands(new Move(this).getCommands()); var temp = new List <Command>(); Action <ServerMessage, string> h = (x, y) => { String[] split = y.Split(new String[] { "\n" }, StringSplitOptions.RemoveEmptyEntries); Console.WriteLine("invoking " + split.Length + " commands"); foreach (string s in split) { var res = parseMessageString(s); Commandlist[res.Item1].invoke(x, res.Item2); } Console.WriteLine("invocation complete"); }; temp.Add(Command.AdminCommand(this, "multicommand", h, new HelpMsgStrings("", ""))); addCommands(temp); } catch (Exception e) { Console.WriteLine("something went wrong setting up the server: " + e); } Console.WriteLine("Connected with server: " + server.Name); }