Exemple #1
0
        public static void Build()
        {
            Directory.CreateDirectory(path);
            foreach (var file in Directory.GetFiles(path))
            {
                var token = new FileInfo(file).Name.Replace("#", string.Empty).Replace(".tcapp", string.Empty);

                try
                {
                    XDocument xd1 = new XDocument();
                    xd1 = XDocument.Load(file);
                }
                catch
                {
                    var app = new AppFile().Process(token);
                    if (app != null)
                    {
                        app.Save(token);
                    }
                    else
                    {
                        File.Delete(file);
                    }
                }
            }
        }
Exemple #2
0
        public async Task ReviewApplication([Remainder] string ticketnumber = default(string))
        {
            var unserializefiles = new List <string>();

            foreach (string file in Directory.GetFiles(TCProgram.path))
            {
                var f  = file;
                var af = new AppFile();
                try
                {
                }
                catch
                {
                    var afile = new AppFile().Process(new FileInfo(f).Name.Replace("#", string.Empty).Replace(".tcapp", string.Empty));
                    afile.id = Context.User.Id;
                    afile.Save(ticketnumber);
                    af.Load(f);
                }
            }


            Directory.CreateDirectory(TCProgram.path);
            if (!string.IsNullOrEmpty(ticketnumber))
            {
                await ReplyAsync("", false, new AppFile().Load(ticketnumber).ToString());
            }
            else
            {
                var files = Directory.GetFiles(TCProgram.path);
                if (files.Length <= 3)
                {
                    foreach (var file in files)
                    {
                        await ReplyAsync($"Index {files.ToList().IndexOf(file)}", false, new AppFile().Load(new FileInfo(file).Name.Replace("#", string.Empty).Replace(new FileInfo(file).Extension, string.Empty)).ToString());
                    }
                }
                else
                {
                    await ReplyAsync("There is way to many result they will be DM to you");

                    foreach (var file in files)
                    {
                        await Context.User.SendMessageAsync($"Index {files.ToList().IndexOf(file)}", false, new AppFile().Load(new FileInfo(file).Name.Replace("#", string.Empty).Replace(new FileInfo(file).Extension, string.Empty)).ToString());
                    }
                }
            }
        }
Exemple #3
0
        public async Task DenyApplicationAsync(string ticketnumber, [Remainder] string reason = default(string))
        {
            var file = new AppFile().Load(ticketnumber);

            file.ticketStatus = AppFile.TicketStatus.Rejected;
            EmbedBuilder embed = new EmbedBuilder();

            embed.Color       = Color.DarkRed;
            embed.Title       = "***SORRY***";
            embed.Description = "You have been not been approved for the for a role see details below.";
            if (!string.IsNullOrEmpty(reason))
            {
                embed.AddField("MessageFrom the Staff", reason);
            }
            await file.GetUser.SendMessageAsync("", false, embed.Build());

            file.Save(ticketnumber);
        }
Exemple #4
0
        public async Task AcceptApplicationAsync(string ticketnumber)
        {
            var file      = new AppFile().Load(ticketnumber);
            var role      = Context.Guild.Roles.FirstOrDefault(x => x.Name == file.role.ToString());
            var guilduser = TCProgram.client.GetGuild(Settings.Default.TCGuild).GetUser(file.id);

            if (!guilduser.Roles.Contains(role))
            {
                await guilduser.AddRoleAsync(role);

                EmbedBuilder embed = new EmbedBuilder();
                embed.Color       = Color.Green;
                embed.Title       = "***CONGRADULATIONS***";
                embed.Description = "You have been approved for the for a role see details below.";
                embed.AddField("MessageFrom the Staff",
                               $"Congratulation { file.GetUser.Mention } you have given the { file.role } role and this " +
                               $"will take effect immodestly if you have any question you can ask them in the { TCProgram.client.GetChannel(Settings.Default.StaffChannelID) }.");

                await file.GetUser.SendMessageAsync("", false, embed.Build());

                file.ticketStatus = AppFile.TicketStatus.Accepted;
            }
            else
            {
                EmbedBuilder embed = new EmbedBuilder();
                embed.Color       = Color.Green;
                embed.Title       = "***Thank you***";
                embed.Description = "Role Already assigned.";
                embed.AddField("MessageFrom the Staff",
                               $"Okay so it seam like you alrady have the { file.role } role and so we will keep that on file " +
                               $"no need to worry, if you have any question you can ask them in the { TCProgram.client.GetChannel(Settings.Default.StaffChannelID) }.");

                await file.GetUser.SendMessageAsync("", false, embed.Build());

                file.ticketStatus = AppFile.TicketStatus.Accepted;
            }
            file.Save(file.ticketNumber);
        }
Exemple #5
0
        public async Task RevokeApplicationAsync(string ticketnumber)
        {
            var file      = new AppFile().Load(ticketnumber);
            var role      = Context.Guild.Roles.FirstOrDefault(x => x.Name == file.role.ToString());
            var guilduser = TCProgram.client.GetGuild(Settings.Default.TCGuild).GetUser(file.id);

            if (guilduser.Roles.Contains(role))
            {
                await guilduser.RemoveRoleAsync(role);

                EmbedBuilder embed = new EmbedBuilder();
                embed.Color       = Color.DarkRed;
                embed.Title       = "***SORRY***";
                embed.Description = "You role has been revoked.";
                embed.AddField("MessageFrom the Staff",
                               $"Sorry  { file.GetUser.Mention } your role {file.role}  has been taken away." +
                               $"will take effect immodestly if you have any question you can ask one of the admins genaral chat.");

                await file.GetUser.SendMessageAsync("", false, embed.Build());

                file.ticketStatus = AppFile.TicketStatus.Revoked;
            }
            else
            {
                EmbedBuilder embed = new EmbedBuilder();
                embed.Color       = Color.DarkRed;
                embed.Title       = "***SORRY***";
                embed.Description = "Role has been revoked.";
                embed.AddField("MessageFrom the Staff",
                               $"Sorry but that user { file.GetUser.Mention } doesn't have {file.role} role.");

                await Context.User.SendMessageAsync("", false, embed.Build());

                file.ticketStatus = AppFile.TicketStatus.Revoked;
            }
            file.Save(file.ticketNumber);
        }
Exemple #6
0
        public async Task ApplyForStaffAsync([Remainder] string app = default(string))
        {
            Directory.CreateDirectory(TCProgram.path);
            if (string.IsNullOrEmpty(app))
            {
                await ReplyAsync(":no_entry_sign:  Staff Application was not recieved");

                EmbedBuilder builder = new EmbedBuilder();
                builder.Title       = Settings.Default.StaffApplicationTitle;
                builder.Description = Settings.Default.StaffApplicationDescription;
                var footer = new EmbedFooterBuilder();
                footer.Text    = Settings.Default.StaffApplicationFooter;
                footer.IconUrl = Settings.Default.StaffApplicationIcon;

                builder.Footer = footer;
                var c = Settings.Default.StaffApplicationColor;
                var r = c.R;
                var g = c.G;
                var b = c.B;
                var a = c.A;
                builder.Color = new Color(r, g, b);

                var demoname       = "&user";
                var demoage        = 100;
                var demorole       = AppFile.Role.None;
                var demoabout      = "Example";
                var demoexperiance = "Example";
                var demoreason     = "Example";
                builder.AddField("Layout Exampel",
                                 $"```\n" +
                                 $"!staffapply\n" +
                                 $"Name: {demoname}\n" +
                                 $"Age: {demoage}\n" +
                                 $"Role: {demorole}\n" +
                                 $"About: {demoabout}\n" +
                                 $"Experiance: {demoexperiance}\n" +
                                 $"Reason: {demoreason}\n" +
                                 $"```\n" +
                                 $"***Note***\n" +
                                 $"MAKE SURE YOU DO !staffapp on the first line ALSO EVERYTHING MUST BE ON IT'S OWN LINE\n" +
                                 $"for the username field you must use `&user` so that discord will find you properly."
                                 );

                await ReplyAsync("", false, builder.Build());
            }
            else
            {
                Random r         = new Random();
                var    code      = Guid.NewGuid().ToString();
                var    codeparts = code.Split('-');

                var ticketnumber1 = r.Next(0, codeparts.Length - 1);
                var ticketnumber2 = r.Next(0, codeparts.Length - 1);

                var ticketnumber = (codeparts[ticketnumber1] + "-" + codeparts[ticketnumber2]).ToUpper();


                await Context.User.SendMessageAsync($":white_check_mark: Staff Application has been recieved and will be look over by one of our admis, thank you\n" +
                                                    $"Your ticket number: `{ticketnumber}`");

                app = app.Replace("```", string.Empty);
                app = app.Replace("&user", $"{Context.User.Username }#{Context.User.Discriminator}");

                if (!Directory.Exists(TCProgram.path))
                {
                    Directory.CreateDirectory(TCProgram.path);
                }
                StreamWriter sw = new StreamWriter(TCProgram.path + $"#{ticketnumber}.tcapp", false);
                sw.WriteLine($"Staff Application");
                sw.WriteLine($"Date: {DateTime.Now.ToShortDateString()}");
                sw.WriteLine($"Time: {DateTime.Now.ToShortTimeString()}");
                sw.WriteLine($"Ticket Number: {ticketnumber}");
                sw.WriteLine($"Ticket Status: {AppFile.TicketStatus.Open}");
                sw.Write(app);
                sw.Flush();
                sw.Close();


                //varify application layout
                var lines = File.ReadLines(TCProgram.path + $"#{ticketnumber}.tcapp").ToList();
                if (lines.Count != 11)
                {
                    await Context.User.SendMessageAsync(
                        $":white_check_mark: your staff applicatin dont seam to be in the right format\n" +
                        $"Do `!staffapply` to view an example.");

                    try { File.Delete(TCProgram.path + $"#{ticketnumber}.tcapp"); } catch { }
                }
                else
                {
                    var file = new AppFile().Process(ticketnumber);
                    file.id = Context.User.Id;
                    file.Save(ticketnumber);

                    await TCProgram.client.GetGuild(Settings.Default.TCGuild).GetTextChannel(Settings.Default.StaffChannelID).SendMessageAsync(
                        $":white_check_mark: { Context.User.Mention }'s Staff Application has been sumited\n" +
                        $"It is currently waiting for reviewed.\n" +
                        $"Do `!staffappreview` to see how many applications are open" +
                        $"Do `!staffappreview {ticketnumber}` to review\n" +
                        $"Do `!staffappaccept {ticketnumber}` to accept\n" +
                        $"Do `!staffappdeny {ticketnumber}` to deny\n" +
                        $"Do `!staffappdeny {ticketnumber}` 'reason-hea' to deny and reply to the sender");
                }
            }
        }