예제 #1
0
        public async Task RemoveItem(int index)
        {
            DiscordServer server = DiscordServer.GetServerFromID(Context.Guild.Id);

            if (server != null)
            {
                if (server.lootItems != null || server.lootItems.Count > 0)
                {
                    try
                    {
                        if (server.lootItems[index - 1] == null)
                        {
                            await ReplyAsync("There is no item at index " + index);
                        }
                        else
                        {
                            server.lootItems.RemoveAt(index - 1);
                            await ReplyAsync("Item Removed...");

                            server.SaveData();
                        }
                    }
                    catch (Exception)
                    {
                        await ReplyAsync("There is no item at index " + index);
                    }
                }
            }
        }
예제 #2
0
        public Task OnLeftGuild(SocketGuild guild)
        {
            DiscordServer server = DiscordServer.GetServerFromID(guild.Id);

            if (server != null)
            {
                DiscordServer.DeleteServerFile(guild);
                discordServers.Remove(server);
            }
            return(Task.CompletedTask);
        }
예제 #3
0
        public Task OnUserJoined(SocketGuildUser user)
        {
            DiscordServer server = DiscordServer.GetServerFromID(user.Guild.Id);

            if (server != null)
            {
                ((SocketTextChannel)server.WelcomeChannel).SendMessageAsync("Welcome to the server " + user.Mention + "!");
                user.AddRoleAsync(server.WelcomeRole);
                server.Users.Add(new ServerUser(user));
            }
            return(Task.CompletedTask);
        }
예제 #4
0
        public async Task Slot(float betPoints)
        {
            DiscordServer server = DiscordServer.GetServerFromID(Context.Guild.Id);

            if (betPoints < server.minimumBetPoints)
            {
                await ReplyAsync("You cant gamble less than + " + server.minimumBetPoints + " points!");

                return;
            }
            await StartSlotting(betPoints);
        }
예제 #5
0
        public async Task SetMinimumBetPoints(float points = 10)
        {
            DiscordServer server = DiscordServer.GetServerFromID(Context.Guild.Id);

            if (points > 0)
            {
                server.minimumBetPoints = points;
                await ReplyAsync("Minimum bet points set to: " + points);
            }
            else
            {
                await ReplyAsync("Minimum points cannot be lower than 1");
            }
        }
예제 #6
0
        public async Task AddItem(string name, string description = "", string link = "")
        {
            DiscordServer server = DiscordServer.GetServerFromID(Context.Guild.Id);

            if (server != null)
            {
                if (server.lootItems == null)
                {
                    server.lootItems = new List <LootItem>();
                }
                server.lootItems.Add(new LootItem(name, description, link));
                await ReplyAsync("Added " + name + " as a loot.");

                server.SaveData();
            }
        }
예제 #7
0
        public async Task Paginate()
        {
            DiscordServer server = DiscordServer.GetServerFromID(Context.Guild.Id);

            if (server != null)
            {
                Console.WriteLine(server.lootItems.Count);
                if (server.lootItems == null || !(server.lootItems.Count > 0))
                {
                    await ReplyAsync("There is no loot.");

                    return;
                }
                var pages = new List <string>();

                int    itemPage   = 0;
                int    itemNumber = 0;
                string page       = "";
                foreach (LootItem item in server.lootItems)
                {
                    itemPage++;
                    itemNumber++;
                    page += itemNumber + " - " + item.Name + " : " + item.Description + "\n";
                    if (itemPage > 5)
                    {
                        itemPage = 0;
                        pages.Add(page);
                        page = "";
                    }
                }
                if (page != "")
                {
                    pages.Add(page);
                }

                var message = new PaginatedMessage(pages, "Reward List", new Color(0xb100c1), Context.User);

                await paginator.SendPaginatedMessageAsync(Context.Channel, message);
            }
        }
예제 #8
0
        public async Task StartSlotting(float betPoints)
        {
            DiscordServer server = DiscordServer.GetServerFromID(Context.Guild.Id);

            if (server == null)
            {
                return;
            }

            ServerUser user = server.Users.Find(x => x.userID == Context.User.Id);

            if (user == null)
            {
                return;
            }

            if (user.Points < betPoints)
            {
                await ReplyAsync("You dont have enough points to bet: " + betPoints + "! (" + user.Points + ")");

                return;
            }
            user.Points -= betPoints;

            int[]         one          = int3();
            int[]         two          = int3();
            int[]         three        = int3();
            List <string> selectedRoll = new List <string>()
            {
                rolls[one[0]],
                rolls[two[0]],
                rolls[three[0]],

                rolls[one[1]],
                rolls[two[1]],
                rolls[three[1]],

                rolls[one[2]],
                rolls[two[2]],
                rolls[three[2]]
            };
            bool won = false;

            if (selectedRoll[0] == selectedRoll[1] && selectedRoll[0] == selectedRoll[2])
            {
                won = true;
            }
            else if (selectedRoll[3] == selectedRoll[4] && selectedRoll[3] == selectedRoll[5])
            {
                won = true;
            }
            else if (selectedRoll[6] == selectedRoll[7] && selectedRoll[6] == selectedRoll[8])
            {
                won = true;
            }

            LootItem wonItem = null;

            if (server.lootItems.Count > 0)
            {
                wonItem = server.lootItems[Program.random.Next(0, server.lootItems.Count)];
            }

            Embed newEmbed = new EmbedBuilder()
                             .WithTitle("Slot Machine")
                             .WithColor(Program.embedColor)
                             .WithTimestamp(DateTimeOffset.Now)
                             .WithFooter(footer => {
                footer
                .WithText("Slot Machine");
            })
                             .AddField("D-did you win?",
                                       selectedRoll[0] + " | " + selectedRoll[1] + " | " + selectedRoll[2] + "\n"
                                       + selectedRoll[3] + "  | " + selectedRoll[4] + "  | " + selectedRoll[5] + "\n"
                                       + selectedRoll[6] + "  | " + selectedRoll[7] + "  | " + selectedRoll[8] + "")
                             .AddField("Results:", "Betting: " + betPoints + " Points.\n" +
                                       (won ? "Won: " + (server.lootItems != null || server.lootItems.Count > 0 ? wonItem.Name : "Nothing") : "Lost: " + betPoints + " Points.")).Build();

            await ReplyAsync("", false, newEmbed);

            GlobalUser gUser = Program.globalUsers.Find(x => x.UserID == Context.User.Id);

            if (won && server.lootItems.Count > 0)
            {
                if (gUser != null)
                {
                    await Rewards.SendReward(gUser, wonItem, (SocketTextChannel)Context.Channel);
                }
            }

            if (string.IsNullOrEmpty(gUser?.email) && won)
            {
                await ReplyAsync("We reccomend you to register your email so we can send you the rewards. PM " + Program._client.CurrentUser.Mention + " your email!");
            }
        }
예제 #9
0
        public async Task Slot()
        {
            DiscordServer server = DiscordServer.GetServerFromID(Context.Guild.Id);

            await Slot(server.minimumBetPoints);
        }