Esempio n. 1
0
        public Report(OrikivoCommandContext ctx, RestUserMessage message)
        {
            List <Embed> embeds = message.Embeds.ToList();

            if (embeds.Count > 0)
            {
                EmbedBuilder e = embeds.FirstOrDefault().ToEmbedBuilder();

                string sbj = "Subject: ";
                string bid = "BugID: ";

                string[] title = e.Title.Split('\n');

                string.Join("\n", title).Debug();


                string[] top = title[0].Split(" | ");
                string.Join(" | ", top).Debug();


                string emoji = top[0];

                string fullname = top[1];
                fullname.Debug("fullname length");

                string username = fullname.Substring(0, fullname.Length - 5);

                Debugger.Write("i passed this 5");
                // force ignore hashtag.
                string discriminator = top[1].Substring(username.Length + 1);

                Debugger.Write("i passed this 6");
                string sid = e.Footer.Text.Substring(bid.Length);

                Debugger.Write("i passed this 7");
                string command = top[2];
                Debugger.Write("i passed this 8");

                Emoji      flag = new Emoji(emoji.Unescape());
                SocketUser u    = ctx.Client.GetUser(username, discriminator);

                if (!u.Exists())
                {
                    ctx.Channel.SendMessageAsync($"user not found ({username}, {discriminator})");
                    throw new Exception("Invalid User: No User Fits the Statement.");
                }

                string subject = title[1].Substring(sbj.Length).TryUnwrap("**");
                string content = e.Description;
                ulong  id      = ulong.Parse(sid);

                Id      = id;
                Author  = new Author(u);
                Type    = flag.GetFlagType();
                Command = command;
                Subject = subject;
                Content = content;
                return;
            }

            throw new Exception("Invalid Message: No Embeds in Container.");
        }