public static async void Help(object s, MessageEventArgs e) { foreach (KeyValuePair <string, Command[]> Cat in Categories) { string CatInfo = string.Empty; foreach (Command Cmd in Cat.Value) { string Start = CmdPrefix; if (Cmd.Prefix == Command.PrefixType.None) { continue; } else if (Cmd.Prefix == Command.PrefixType.Mention) { Start = Bot.Mention + " "; } if (Db.HasPermission(e.User.Id, Cmd.Keys[0])) { if (e.User.Id == Bot.Owner) { CatInfo += "(" + Db.PermissionRank(Cmd.Keys[0]) + ") "; } CatInfo += Start + string.Join("/", Cmd.Keys) + " ~ `" + Cmd.Description + "`\n"; } } if (CatInfo != string.Empty) { if (Db.ChannelDisabledCategory(e.Channel.Id, Cat.Key)) { if (e.User.Id == Bot.Owner) { CatInfo = "Disabled"; } else { continue; } } e.Respond((Cat.Key == string.Empty ? "**Main**" : "**" + Cat.Key + "**") + "\n" + CatInfo); await Task.Delay(250); } } }
public static void Handle(MessageEventArgs e) { try { ServerData S = ServerData.Servers[e.Server.Id]; if (S.Trivia.ContainsKey(e.Channel.Id) && S.Trivia[e.Channel.Id].Try(e)) { return; } List <Command> Cmds = S.GetCommands(e.Channel.Id); string Raw = e.Message.RawText; if (e.Message.Text.StartsWith("{") && e.Message.Text.EndsWith("}") && Db.HasPermission(e.User.Id, "anime")) { Search.AnimeInfo(Raw.TrimStart('{').TrimEnd('}'), e); } else if (e.Message.Text.StartsWith("<") && !e.Message.Text.StartsWith("<@") && e.Message.Text.EndsWith(">") && Db.HasPermission(e.User.Id, "manga")) { Search.MangaInfo(Raw.TrimStart('<').TrimEnd('>'), e); } string Key; string Lower; foreach (Command Cmd in Cmds) { string Prefix = CmdPrefix; Lower = Raw.ToLower(); if (Cmd.Prefix != Command.PrefixType.None) { if (Db.HasPermission(e.User.Id, Cmd.Keys[0])) { if (Cmd.Prefix == Command.PrefixType.Mention) { Prefix = Bot.Mention + " "; } foreach (string CmdKey in Cmd.Keys) { Key = Prefix + CmdKey; if (Lower.StartsWith(Key) && (Raw.Length == Key.Length || Raw.Substring(Key.Length, 1) == " " || Raw.Substring(Key.Length, 1) == "." || Raw.Substring(Key.Length, 1) == "?")) { Cmd.Handler(Raw.Substring(Key.Length).TrimStart(' '), e); Executed++; return; } } } } else if (Lower.Contains(Cmd.Keys[0])) { Executed++; Cmd.Handler(Raw, e); return; } } if (Raw.StartsWith(Bot.Mention) && Raw.EndsWith("?") && Db.HasPermission(e.User.Id, "ask") && Cmds.Any(x => x.Keys.Contains("ask"))) { Search.Ask(Raw, e); } } catch (Exception Ex) { $"CommandExeption: {Ex}".Log(); } }