コード例 #1
0
        public async Task Invasions(SocketMessage message)
        {
            string receivedData = await SupportMethods.MakeAPIRequest("https://api.warframestat.us/pc/en/invasions", message);//makes an api call to get current data

            if (receivedData == null)
            {
                return;                                         //makes sure that something is returned to avoid errors in deserialization
            }
            definitions.InvasionDefinitions[] currentInvasions; //initializing variable
            try                                                 //try deserializing
            {
                currentInvasions = JsonSerializer.Deserialize <definitions.InvasionDefinitions[]>(receivedData);
            }
            catch (Exception e)//catches exeptions and lets the user now what happened
            {
                Console.WriteLine(e);
                await message.Channel.SendMessageAsync("JSON error. please let me(actinoide#6637) know");

                return;
            }
            string messageToSend = @"```";//initializing variable

            foreach (definitions.InvasionDefinitions invasion in currentInvasions)
            {//adding each invasion data to the string
                messageToSend += invasion.attackingFaction + " " + invasion.defendingFaction + " " + invasion.attackerReward.asString + " " + invasion.defenderReward.asString + " " + invasion.node + Environment.NewLine;
            }
            await message.Channel.SendMessageAsync(messageToSend + @"```");//sends the generated string as a discord message

            return;
        }
コード例 #2
0
        public async Task Events(SocketMessage message)
        {
            string receivedData = await SupportMethods.MakeAPIRequest("https://api.warframestat.us/pc/en/events", message);//makes an api call to get current data

            if (receivedData == null)
            {
                return;                                   //makes sure that something is returned to avoid errors in deserialization
            }
            definitions.EventDefinitions[] currentEvents; //initializing variable
            try                                           //try deserializing
            {
                currentEvents = JsonSerializer.Deserialize <definitions.EventDefinitions[]>(receivedData);
            }
            catch (Exception e)//catches exeptions and lets the user now what happened
            {
                Console.WriteLine(e);
                await message.Channel.SendMessageAsync("JSON error. please let me(actinoide#6637) know");

                return;
            }
            string messageToSend = @"```";//initializing variable

            foreach (definitions.EventDefinitions cevent in currentEvents)
            {//adding each fissures data to the string
                messageToSend += cevent.description + " ";
                foreach (definitions.InterimSteps interimSteps in cevent.interimSteps)
                {
                    messageToSend += interimSteps.goal + ":" + interimSteps.reward.asString + " ";
                }
                messageToSend += cevent.maximumScore + ":";
                foreach (definitions.Rewards reward in cevent.rewards)
                {
                    messageToSend += reward.asString + " ";
                }
                messageToSend += Environment.NewLine;
            }
            await message.Channel.SendMessageAsync(messageToSend + @"```");//sends the generated string as a discord message

            return;
        }