示例#1
0
        public static async Task PerformAsync(ISocketMessageChannel channel, Discord.IUserMessage message, Discord.Emoji candidate, DataBase db)
        {
            if (!(channel is SocketGuildChannel guildChannel))
            {
                return;
            }

            var guild = Guild.FindOrCreate.Perform(guildChannel.Guild, db);

            var author = message.Embeds.First().Author.Value;

            var description = message.Embeds.First().Fields.Last().Value;

            var id = Convert.ToInt32(description.Substring(description.IndexOf('#') + 1).Split("\n")[0]);

            var card = Helpers.FindById.Perform(id);

            var cards = Views.Card.GetAssociatedCards(card);

            var childCard = cards[Views.Card.Labels.IndexOf(candidate)];

            await Helpers.SendCards.PerformAsync(channel, new Models.Card[] { childCard.Item1 }, guild.DisplaySetting, guild.Language);
        }
示例#2
0
        /// <summary>
        /// Selects the appropriate cs go container to open, user replies with a number corrosponding to the case, the paginator message showing case options will also be deleted
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static async Task SelectOpenCase(SocketCommandContext context, string input, Discord.IUserMessage sentMessage)
        {
            //Delete the pagination message after receiving user input
            await sentMessage.DeleteAsync();


            var continers = CsgoUnboxingHandler.csgoContiners.Containers.Where(c => c.Name != null).ToList();

            //Try to turn user input to string
            int       userInput             = 0;
            Container userSelectedContainer = new Container();

            try
            {
                userInput = int.Parse(input);

                //Get the case user selected
                userSelectedContainer = continers[userInput];
            }
            catch (Exception)
            {
                await context.Channel.SendMessageAsync(UserInteraction.BoldUserName(context) + ", Please input a valid number");

                return;
            }

            //Set user case preference
            if (!CsgoUnboxingHandler.userSelectedCase.TryGetValue(context.Message.Author.Id, out var t))
            {
                //If user does not exist, generate and set
                CsgoUnboxingHandler.userSelectedCase.Add(context.Message.Author.Id, userSelectedContainer.Name);
            }
            else
            {
                //If user does exist, only set
                CsgoUnboxingHandler.userSelectedCase[context.Message.Author.Id] = userSelectedContainer.Name;
            }

            await context.Channel.SendMessageAsync(UserInteraction.BoldUserName(context) + $", You set your case to open to **{userSelectedContainer.Name}**");
        }