Ejemplo n.º 1
0
        public static Task <bool> RemoveAdmin(string id)
        {
            return(Task.Run(() =>
            {
                int count = 0;
                if (id == "")
                {
                    return false;
                }
                else
                {
                    string[] admins = File.ReadAllLines("Users/admins.json");

                    foreach (var admin in admins)
                    {
                        count++;
                        Admin a = SSRPItems.ReadFromJsonFile <Admin>(admin);

                        if (a.id == id)
                        {
                            var file = new List <string>(System.IO.File.ReadAllLines("Users/admins.json"));
                            file.RemoveAt(count - 1);
                            File.WriteAllLines("Users/admins.json", file.ToArray());
                            return true;
                        }
                    }

                    return false;
                }
            }));
        }
Ejemplo n.º 2
0
        public static Task <bool> RemoveLink(string id)
        {
            return(Task.Run(() =>
            {
                int count = 0;
                if (id.Length == 0)
                {
                    return false;
                }
                else
                {
                    string[] admins = File.ReadAllLines("LinkedSignatures/linkedSignatures.json");

                    foreach (var admin in admins)
                    {
                        count++;
                        LinkSignature ls = SSRPItems.ReadFromJsonFile <LinkSignature>(admin);

                        if (ls.DiscordID == id)
                        {
                            var file = new List <string>(System.IO.File.ReadAllLines("LinkedSignatures/linkedSignatures.json"));
                            file.RemoveAt(count - 1);
                            File.WriteAllLines("LinkedSignatures/linkedSignatures.json", file.ToArray());
                            linkedSigs = SSRPItems.FillList <LinkSignature>("LinkedSignatures/linkedSignatures.json");

                            return true;
                        }
                    }

                    return false;
                }
            }));
        }
Ejemplo n.º 3
0
    public async Task AddItemAsync(string itemname, string aliases)
    {
        if (itemname == "" | aliases == "")
        {
            return;
        }

        if (PermissionManager.GetPerms(Context.Message.Author.Id) < PermissionConfig.Admin)
        {
            await Context.Channel.SendMessageAsync("Not authorised to run this command."); return;
        }
        else
        {
            string[]       aliasList = aliases.Split(',');
            SSRPItems.Bind newBind   = new SSRPItems.Bind {
                bind = $"{itemname}", aliases = aliasList
            };
            SSRPItems.WriteToJsonFile <SSRPItems.Bind>("Items/binds.json", newBind, true);
            SSRPItems.bindList.Add(newBind);

            await Context.Channel.SendMessageAsync($"New Item Has Been Added. Name: {itemname} | Bind: zarp_equipitem {itemname}");

            await Utilities.StatusMessage("bind", Context);
        }
    }
Ejemplo n.º 4
0
    public async Task SendItemInfo([Remainder] string item)
    {
        if (PermissionManager.GetPerms(Context.Message.Author.Id) < PermissionConfig.User)
        {
            await Context.Channel.SendMessageAsync("Not authorised to run this command."); return;
        }
        SSRPItems.Item i = await SSRPItems.GetItem(item);

        if (i == null)
        {
            await Context.Channel.SendMessageAsync("Item not found. Try using the item's exact name, eg: m9k_psg1"); await Utilities.StatusMessage("item", Context);
        }
        else
        {
            EmbedBuilder       eb = new EmbedBuilder();
            EmbedFooterBuilder fb = new EmbedFooterBuilder();


            fb.WithText($"Called by {Context.Message.Author.Username}");
            fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

            eb.WithTitle($"{i.itemName}");
            eb.AddField("Description", $"{i.itemDesc}");
            eb.AddField("Weight", $"{i.weight}");
            eb.WithColor(Color.Blue);
            eb.WithFooter(fb);

            await ReplyAsync("", false, eb.Build());

            await Utilities.StatusMessage("item", Context);
        }
    }
    public async Task ReloadItemsAsync()
    {
        if (PermissionManager.GetPerms(Context.Message.Author.Id) < PermissionConfig.Admin)
        {
            await Context.Channel.SendMessageAsync("Not authorised to run this command."); return;
        }

        //SSRP Item lists
        SSRPItems.bindList    = SSRPItems.FillList <SSRPItems.Bind>("Items/binds.json");
        SSRPItems.printerList = SSRPItems.FillList <SSRPItems.Printer>("Items/printers.json");
        SSRPItems.itemList    = SSRPItems.FillList <SSRPItems.Item>("Items/items.json");
        SSRPItems.suitList    = SSRPItems.FillList <SSRPItems.Suit>("Items/suits.json");
        SSRPItems.caseList    = SSRPItems.FillList <SSRPItems.Case>("Items/cases.json");

        //Leaderboard lists
        LeaderboardUtils.boards     = SSRPItems.FillList <LeaderboardUtils.Boards>("Leaderboards/boards.json");
        LeaderboardUtils.categories = SSRPItems.FillList <LeaderboardUtils.Categories>("Leaderboards/categories.json");

        //Link list
        LinkedSignatures.linkedSigs = SSRPItems.FillList <LinkedSignatures.LinkSignature>("LinkedSignatures/linkedSignatures.json");

        await Context.Channel.SendMessageAsync("All item lists have been reloaded. Any changes to any item files are now in effect.");

        await Utilities.StatusMessage("reloaditems", Context);
    }
Ejemplo n.º 6
0
    public async Task SendCase([Remainder] string item)
    {
        if (PermissionManager.GetPerms(Context.Message.Author.Id) < PermissionConfig.User)
        {
            await Context.Channel.SendMessageAsync("Not authorised to run this command."); return;
        }

        StringBuilder sb    = new StringBuilder();
        int           count = 0;

        SSRPItems.Case c = await SSRPItems.GetCase(item);

        if (c == null)
        {
            await Context.Channel.SendMessageAsync("Specified case not found. You can request for it to be added by contacting an Admin."); return;
        }

        foreach (string i in c.items)
        {
            sb.Append($"Item: {i} | Odds: {c.odds[count]}%\n");
            count++;
        }

        await Context.Channel.SendMessageAsync($"{Context.Message.Author.Mention}\n```--- The {c.caseName} Case ---\n{sb.ToString()}```");

        await Utilities.StatusMessage("case", Context);
    }
Ejemplo n.º 7
0
    public async Task ReloadLinksAsync()
    {
        if (PermissionManager.GetPerms(Context.Message.Author.Id) < PermissionConfig.Admin)
        {
            await Context.Channel.SendMessageAsync("Not authorised to run this command."); return;
        }
        linkedSigs = SSRPItems.FillList <LinkSignature>("LinkedSignatures/linkedSignatures.json");
        await Context.Channel.SendMessageAsync("Linked accounts have been reloaded.");

        await Utilities.StatusMessage("reloadlinks", Context);
    }
Ejemplo n.º 8
0
    public async Task SendBind([Remainder] string item)
    {
        if (PermissionManager.GetPerms(Context.Message.Author.Id) < PermissionConfig.User)
        {
            await Context.Channel.SendMessageAsync("Not authorised to run this command."); return;
        }

        SSRPItems.Suit s = await SSRPItems.GetSuit(item);

        if (s == null)
        {
            await Context.Channel.SendMessageAsync("Specified suit not found. You can request for it to be added by contacting an Admin."); return;
        }

        await Context.Channel.SendMessageAsync($"{Context.Message.Author.Mention}\n```--- The {s.suitName} ---\nHP: {s.hp}\nArmor: {s.armor}\nSpeed: {s.speed}\nAbility: {s.ability}```");

        await Utilities.StatusMessage("suit", Context);
    }
Ejemplo n.º 9
0
        public static Task <bool> AddAdmin(ulong id, string name, int permLevel)
        {
            return(Task.Run(() =>
            {
                if (CheckAdmin(id).Result)
                {
                    return false;
                }

                Admin a = new Admin {
                    id = id.ToString(), name = name, permLevel = permLevel
                };
                SSRPItems.WriteToJsonFile <Admin>("Users/admins.json", a, true);
                admins.Add(a);

                return true;
            }));
        }
Ejemplo n.º 10
0
    public async Task SendBind(char key, [Remainder] string item)
    {
        if (PermissionManager.GetPerms(Context.Message.Author.Id) < PermissionConfig.User)
        {
            await Context.Channel.SendMessageAsync("Not authorised to run this command."); return;
        }

        string bind = await SSRPItems.GetBind(item.ToLower());

        if (bind == null)
        {
            await Context.Channel.SendMessageAsync("Specified item not found. You can request for it to be added by contacting an Admin."); return;
        }

        await Context.Channel.SendMessageAsync($"The bind you are looking for is: `bind {key} \"zarp_equipitem {bind}\"`");

        await Utilities.StatusMessage("bind", Context);
    }
Ejemplo n.º 11
0
    public async Task RemovePrinterAsync(string printerName)
    {
        int count = 0;

        if (printerName == "")
        {
            return;
        }

        if (PermissionManager.GetPerms(Context.Message.Author.Id) < PermissionConfig.Admin)
        {
            await Context.Channel.SendMessageAsync("Not authorised to run this command."); return;
        }
        else
        {
            string[] currPrinters = File.ReadAllLines("Items/printers.json");

            foreach (var printer in currPrinters)
            {
                count++;
                SSRPItems.Printer p = SSRPItems.ReadFromJsonFile <SSRPItems.Printer>(printer);

                if (p.printerName == printerName)
                {
                    var file = new List <string>(System.IO.File.ReadAllLines("Items/printers.json"));
                    file.RemoveAt(count - 1);
                    File.WriteAllLines("Items/printers.json", file.ToArray());

                    await Context.Channel.SendMessageAsync($"Removed {printerName} printer.");

                    await Utilities.StatusMessage("removeprinter", Context);

                    return;
                }
            }

            await Context.Channel.SendMessageAsync($"Printer not found.");

            await Utilities.StatusMessage("removeprinter", Context);
        }
    }
Ejemplo n.º 12
0
    public async Task AddPrinterAsync(string printerName, string colour, double perSecond, string aliases)
    {
        if (PermissionManager.GetPerms(Context.Message.Author.Id) < PermissionConfig.Admin)
        {
            await Context.Channel.SendMessageAsync("Not authorised to run this command."); return;
        }

        if (printerName == "" | aliases == "")
        {
            return;
        }

        string[]          aliasList  = aliases.Split(',');
        SSRPItems.Printer newPrinter = new SSRPItems.Printer {
            printerName = printerName, perSecond = perSecond, aliases = aliasList, color = colour
        };
        SSRPItems.WriteToJsonFile <SSRPItems.Printer>("Items/printers.json", newPrinter, true);
        SSRPItems.printerList.Add(newPrinter);

        await Context.Channel.SendMessageAsync($"New Printer Has Been Added. Name: {printerName} | Per Second: {perSecond.ToString("#,##0")}");

        await Utilities.StatusMessage("addprinter", Context);
    }
Ejemplo n.º 13
0
    public async Task RemoveItemAsync(string itemname)
    {
        if (PermissionManager.GetPerms(Context.Message.Author.Id) < PermissionConfig.Admin)
        {
            await Context.Channel.SendMessageAsync("Not authorised to run this command."); return;
        }
        if (itemname == "")
        {
            return;
        }
        int count = 0;

        string[] currBinds = File.ReadAllLines("Items/binds.json");

        foreach (string bind in currBinds)
        {
            count++;
            SSRPItems.Bind b = SSRPItems.ReadFromJsonFile <SSRPItems.Bind>(bind);

            if (b.bind == itemname)
            {
                var file = new List <string>(System.IO.File.ReadAllLines("Items/binds.json"));
                file.RemoveAt(count - 1);
                File.WriteAllLines("Items/binds.json", file.ToArray());

                await Context.Channel.SendMessageAsync($"Removed {itemname}.");

                await Utilities.StatusMessage("removebind", Context);

                return;
            }
        }

        await Context.Channel.SendMessageAsync($"Could not find {itemname}. Make sure it is typed correctly.");

        await Utilities.StatusMessage("removebind", Context);
    }
Ejemplo n.º 14
0
 public static Task ReloadPermissions()
 {
     admins.Clear();
     admins = SSRPItems.FillList <Admin>("Users/admins.json");
     return(Task.CompletedTask);
 }
Ejemplo n.º 15
0
    public async Task SendPrinter(string item, int boost = 1, int time = 1)
    {
        if (PermissionManager.GetPerms(Context.Message.Author.Id) < PermissionConfig.User)
        {
            await Context.Channel.SendMessageAsync("Not authorised to run this command."); return;
        }

        SSRPItems.Printer p = await SSRPItems.GetPrinter(item);

        Discord.Color c = new Discord.Color(ColorTranslator.FromHtml($"#{p.color}").R, ColorTranslator.FromHtml($"#{p.color}").G, ColorTranslator.FromHtml($"#{p.color}").B);

        if (p == null)
        {
            await Context.Channel.SendMessageAsync("Printer not found. Please enclose the printer name in quotes: `\"name\"`"); await Utilities.StatusMessage("printer", Context);
        }
        else
        {
            //If loot/gem/uranium
            if (p.printerName == "Uranium" || p.printerName == "Loot" || p.printerName == "Gem")
            {
                //If 1, don't print the plural
                if (time == 1)
                {
                    EmbedBuilder       eb = new EmbedBuilder();
                    EmbedFooterBuilder fb = new EmbedFooterBuilder();

                    fb.WithText($"Called by {Context.Message.Author.Username}");
                    fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

                    eb.WithTitle($"{p.printerName}");
                    eb.AddField("Per Second", $"{((p.perSecond * boost) * time).ToString("#,##0")}");
                    eb.AddField("Per Minute", $"{(((p.perSecond * 60) * boost) * time).ToString("#,##0")}");
                    eb.AddField("Per Hour", $"{(((p.perSecond * 60) * 60) * boost).ToString("#,##0")}");
                    eb.AddField("With Boost", $"x{boost}");
                    eb.WithColor(c);
                    eb.WithFooter(fb);

                    await ReplyAsync("", false, eb.Build());

                    await Utilities.StatusMessage("printer", Context);
                }
                else
                {
                    EmbedBuilder       eb = new EmbedBuilder();
                    EmbedFooterBuilder fb = new EmbedFooterBuilder();

                    fb.WithText($"Called by {Context.Message.Author.Username}");
                    fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

                    eb.WithTitle($"{p.printerName}");
                    eb.AddField($"Per {time} Seconds", $"{((p.perSecond * boost) * time).ToString("#,##0")}");
                    eb.AddField($"Per {time} Minutes", $"{(((p.perSecond * 60) * boost) * time).ToString("#,##0")}");
                    eb.AddField($"Per {time} Hours", $"{((((p.perSecond * 60) * 60) * boost) * time).ToString("#,##0")}");
                    eb.AddField($"With Boost", $"x{boost}");
                    eb.WithColor(c);
                    eb.WithFooter(fb);

                    await ReplyAsync("", false, eb.Build());

                    await Utilities.StatusMessage("printer", Context);
                }
            }
            //If normal printer
            else
            {
                //If 1, don't print the plural
                if (time == 1)
                {
                    EmbedBuilder       eb = new EmbedBuilder();
                    EmbedFooterBuilder fb = new EmbedFooterBuilder();

                    fb.WithText($"Called by {Context.Message.Author.Username}");
                    fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

                    eb.WithTitle($"{p.printerName}");
                    eb.AddField("Per Second", $"${((p.perSecond * boost) * time).ToString("#,##0")}");
                    eb.AddField("Per Minute", $"${(((p.perSecond * 60) * boost) * time).ToString("#,##0")}");
                    eb.AddField("Per Hour", $"${(((p.perSecond * 60) * 60) * boost).ToString("#,##0")}");
                    eb.AddField("With Boost", $"x{boost}");
                    eb.WithColor(c);
                    eb.WithFooter(fb);

                    await ReplyAsync("", false, eb.Build());

                    await Utilities.StatusMessage("printer", Context);
                }
                else
                {
                    EmbedBuilder       eb = new EmbedBuilder();
                    EmbedFooterBuilder fb = new EmbedFooterBuilder();

                    fb.WithText($"Called by {Context.Message.Author.Username}");
                    fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

                    eb.WithTitle($"{p.printerName}");
                    eb.AddField($"Per {time} Seconds", $"${((p.perSecond * boost) * time).ToString("#,##0")}");
                    eb.AddField($"Per {time} Minutes", $"${(((p.perSecond * 60) * boost) * time).ToString("#,##0")}");
                    eb.AddField($"Per {time} Hours", $"${((((p.perSecond * 60) * 60) * boost)* time).ToString("#,##0")}");
                    eb.AddField($"With Boost", $"x{boost}");
                    eb.WithColor(c);
                    eb.WithFooter(fb);

                    await ReplyAsync("", false, eb.Build());

                    await Utilities.StatusMessage("printer", Context);
                }
            }
        }
    }