コード例 #1
0
        private async Task <ulong> LodgeTransactionTask(DataBaseHandlingService db, CommandHandlingService CommandService, StockMarketService marketService, int hours, int mins)
        {
            EmbedFieldBuilder typeField    = new EmbedFieldBuilder().WithIsInline(true).WithName("Type:").WithValue($"Industry Auction");
            EmbedFieldBuilder companyField = new EmbedFieldBuilder().WithIsInline(true).WithName("ID:").WithValue(industryID);
            EmbedFieldBuilder amountField  = new EmbedFieldBuilder().WithIsInline(true).WithName("Type:").WithValue((string)await db.GetFieldAsync(industryID, "Type", "industries"));
            EmbedFieldBuilder priceField   = new EmbedFieldBuilder().WithIsInline(true).WithName("Price:").WithValue("$" + price);

            EmbedBuilder emb = new EmbedBuilder().WithTitle("Stock Market Offer").WithDescription($"Use the command `&bid [ticker] {id.ToString()} [price]` to accept this offer.").WithFooter($"Transaction ID: {id.ToString()}").AddField(typeField).AddField(companyField).AddField(amountField).AddField(priceField).WithColor(Color.Green);

            Discord.Rest.RestUserMessage message = await CommandService.PostEmbedTask((string)await db.GetFieldAsync("MarketChannel", "channel", "system"), emb.Build());

            DateTime now       = DateTime.UtcNow;
            DateTime scheduled = now.AddHours(hours).AddMinutes(mins);

            plannedEnd = scheduled;
            JobDataMap map = new JobDataMap();

            map.Add("market", marketService);
            map.Add("auction", this);
            map.Add("command", CommandService);
            map.Add("db", db);
            IJobDetail job     = JobBuilder.Create <Job>().SetJobData(map).Build();
            ITrigger   trigger = TriggerBuilder.Create().WithSimpleSchedule(x => x.WithInterval(TimeSpan.FromMilliseconds(1)).WithRepeatCount(1)).StartAt(plannedEnd).Build();
            await CommandService.scheduler.ScheduleJob(job, trigger);

            return(message.Id);
        }
コード例 #2
0
        public async Task GetCompaniesTask()
        {
            Collection <string> ids = await dataBaseService.getIDs("companies");

            int companyCount = ids.Count;
            Collection <EmbedFieldBuilder> companyEmbedList = new Collection <EmbedFieldBuilder>();

            foreach (string ID in ids)
            {
                Company temp = new Company(await dataBaseService.getJObjectAsync(ID, "companies"));

                EmbedFieldBuilder tempEmb = new EmbedFieldBuilder().WithIsInline(true).WithName($"{temp.name} ({temp.id})").WithValue($"Share Price: ${Math.Round(temp.SharePrice, 2)}. Total Value: ${Math.Round(temp.SharePrice * temp.shares, 2)}. Amount of Shares: {await MarketService.CorpShares(temp.id)}");
                if (companyEmbedList.Count < 25)
                {
                    companyEmbedList.Add(tempEmb);
                }
            }

            EmbedBuilder embed = new EmbedBuilder().WithColor(Color.Gold).WithTitle("Companies").WithDescription("This is a list of all companies").WithFooter($"Total amount of companies: {companyCount}");

            foreach (EmbedFieldBuilder field in companyEmbedList)
            {
                embed.AddField(field);
            }

            await CommandService.PostEmbedTask(Context.Channel.Id.ToString(), embed.Build());
        }
コード例 #3
0
        private async Task <ulong> LodgeTransactionTask(DataBaseHandlingService db, CommandHandlingService CommandService)
        {
            EmbedFieldBuilder typeField    = new EmbedFieldBuilder().WithIsInline(true).WithName("Type:").WithValue($"Looking to {type} industry");
            EmbedFieldBuilder companyField = new EmbedFieldBuilder().WithIsInline(true).WithName("ID:").WithValue(industryID);
            EmbedFieldBuilder amountField  = new EmbedFieldBuilder().WithIsInline(true).WithName("Type:").WithValue(db.GetFieldAsync(industryID, "type", "industry").ToString());
            EmbedFieldBuilder priceField   = new EmbedFieldBuilder().WithIsInline(true).WithName("Price:").WithValue("$" + price);

            EmbedBuilder emb = new EmbedBuilder().WithTitle("Stock Market Offer").WithDescription($"Use the command `&accept {id.ToString()}` to accept this offer.").WithFooter($"Transaction ID: {id.ToString()}").AddField(typeField).AddField(companyField).AddField(amountField).AddField(priceField).WithColor(Color.Green);

            Discord.Rest.RestUserMessage message = await CommandService.PostEmbedTask((string)await db.GetFieldAsync("MarketChannel", "channel", "system"), emb.Build());

            return(message.Id);
        }