示例#1
0
        public async Task WhoIs(CommandMessage message, string serverName, string characterFirstName, string characterLastName)
        {
            CharacterInfo character = await this.GetCharacterInfo(characterFirstName + " " + characterLastName, serverName);

            string file = await CharacterCard.Draw(character);

            await message.Channel.SendFileAsync(file, messageReference : message.MessageReference);
        }
示例#2
0
        public async Task WhoIs(CommandMessage message, string characterName, string serverName)
        {
            CharacterInfo character = await this.GetCharacterInfo(characterName, serverName);

            string file = await CharacterCard.Draw(character);

            await message.Channel.SendFileAsync(file);
        }
示例#3
0
        public async Task PostWhoIsResponse(CommandMessage message, User user, int?characterIndex = null)
        {
            // Special case to just load Kupo Nuts' portrait from disk.
            if (user.DiscordUserId == Program.DiscordClient.CurrentUser.Id)
            {
                await message.Channel.SendMessageAsync("Thats me!");

                await message.Channel.SendFileAsync(PathUtils.Current + "/Assets/self.png");

                return;
            }

            User.Character?defaultCharacter = user.GetDefaultCharacter();
            if (defaultCharacter is null)
            {
                throw new UserException("No characters linked! Use `IAm` to link a character");
            }

            if (characterIndex != null)
            {
                try
                {
                    defaultCharacter = user.Characters[characterIndex.Value - 1];
                }
                catch
                {
                    throw new UserException("I couldn't find a character at index: " + characterIndex);
                }
            }

            // Default character
            CharacterInfo defaultCharacterInfo = await this.GetCharacterInfo(defaultCharacter.FFXIVCharacterId);

            string file = await CharacterCard.Draw(defaultCharacterInfo);

            await message.Channel.SendFileAsync(file, messageReference : message.MessageReference);

            // Get current Verification status
            bool oldIsVerified = defaultCharacter.IsVerified;

            if (!defaultCharacter.CheckVerification(defaultCharacterInfo))
            {
                EmbedBuilder builder = new EmbedBuilder
                {
                    Description = "This character has not been verified.",
                    Color       = Discord.Color.Gold,
                };

                // If this is the requesting users character, give instructions on how to verify
                if (message.Author.Id == user.DiscordUserId)
                {
                    builder.Title       = "This character has not been verified";
                    builder.Description = "To verify this character, enter the following verification code in your [lodestone profile](https://na.finalfantasyxiv.com/lodestone/my/setting/profile/): " + defaultCharacter.FFXIVCharacterVerification;
                }

                await message.Channel.SendMessageAsync(null, false, builder.Build());
            }

            if (!defaultCharacterInfo.HasMinions && !defaultCharacterInfo.HasMounts && !defaultCharacterInfo.HasAchievements)
            {
                EmbedBuilder builder = new EmbedBuilder
                {
                    Description = "To show Minions, Mounts, and Achievements, please link your character at [FFXIV Collect](https://ffxivcollect.com/)",
                };
                await message.Channel.SendMessageAsync(null, false, builder.Build());
            }

            // While building the AKA, we can confirm if a name/server change has occured
            // for queried character and update DB
            // Initial value used to see if verification has been updated
            bool hasChanges = oldIsVerified != defaultCharacter.IsVerified;

            // AKA
            StringBuilder akaDescBuilder = new StringBuilder();
            int           index          = 0;

            foreach (User.Character character in user.Characters)
            {
                // For the queried character, check if the name/server has changed and update
                if (character.FFXIVCharacterId == defaultCharacterInfo.Id &&
                    ((!string.IsNullOrWhiteSpace(defaultCharacterInfo.Name) && character.CharacterName != defaultCharacterInfo.Name) ||
                     (!string.IsNullOrWhiteSpace(defaultCharacterInfo.Server) && character.ServerName != defaultCharacterInfo.Server)))
                {
                    hasChanges = true;
                    character.CharacterName = defaultCharacterInfo.Name;
                    character.ServerName    = defaultCharacterInfo.Server;
                }

                index++;

                akaDescBuilder.Append(index);
                akaDescBuilder.Append(") ");
                akaDescBuilder.Append(character.CharacterName);
                akaDescBuilder.Append(" (");
                akaDescBuilder.Append(Emotes.Home.GetString());
                akaDescBuilder.Append(character.ServerName);
                akaDescBuilder.Append(")");

                if (!await character.IsVerified(user))
                {
                    akaDescBuilder.Append(" *(Not Verified)*");
                }

                akaDescBuilder.AppendLine();
            }

            // Character change detected, save user information
            if (hasChanges)
            {
                _ = UserService.SaveUser(user);
            }

            if (index > 1)
            {
                EmbedBuilder builder = new EmbedBuilder
                {
                    Description = akaDescBuilder.ToString(),
                    Title       = "Also known as:",
                };
                await message.Channel.SendMessageAsync(null, false, builder.Build());
            }
        }
示例#4
0
        public async Task PostWhoIsResponse(CommandMessage message, User user, int?characterIndex = null)
        {
            User.Character?defaultCharacter = user.GetDefaultCharacter();
            if (defaultCharacter is null)
            {
                throw new UserException("No characters linked! Use `IAm` to link a character");
            }

            int index = 0;

            if (characterIndex != null)
            {
                defaultCharacter = null;
                foreach (User.Character character in user.Characters)
                {
                    index++;

                    if (index == characterIndex)
                    {
                        defaultCharacter = character;
                    }
                }

                if (defaultCharacter is null)
                {
                    throw new UserException("I couldn't find a character at index: " + characterIndex);
                }
            }

            // Default character
            CharacterInfo defaultCharacterInfo = await this.GetCharacterInfo(defaultCharacter.FFXIVCharacterId);

            string file = await CharacterCard.Draw(defaultCharacterInfo);

            await message.Channel.SendFileAsync(file);

            if (!defaultCharacter.IsVerified(defaultCharacterInfo))
            {
                EmbedBuilder builder = new EmbedBuilder();
                builder.Description = "This character has not been verified.";
                builder.Color       = Discord.Color.Gold;

                // If this is the requesting users character, give instructions on how to verify
                if (message.Author.Id == user.DiscordUserId)
                {
                    builder.Title       = "This character has not been verified";
                    builder.Description = "To verify this character, enter the following verification code in your [lodestone profile](https://na.finalfantasyxiv.com/lodestone/my/setting/profile/).\n" + defaultCharacter.FFXIVCharacterVerification;
                }

                await message.Channel.SendMessageAsync(null, false, builder.Build());
            }

            if (!defaultCharacterInfo.HasMinions && !defaultCharacterInfo.HasMounts && !defaultCharacterInfo.HasAchievements)
            {
                EmbedBuilder builder = new EmbedBuilder();
                builder.Description = "To show Minions, Mounts, and Achievements, please link your character at [FFXIV Collect](https://ffxivcollect.com/)";
                await message.Channel.SendMessageAsync(null, false, builder.Build());
            }

            // AKA
            StringBuilder akaDescBuilder = new StringBuilder();

            index = 0;
            foreach (User.Character character in user.Characters)
            {
                index++;

                akaDescBuilder.Append(index);
                akaDescBuilder.Append(") ");
                akaDescBuilder.Append(character.CharacterName);
                akaDescBuilder.Append(" (");
                akaDescBuilder.Append(Emotes.Home.GetString());
                akaDescBuilder.Append(character.ServerName);
                akaDescBuilder.Append(")");

                if (!await character.IsVerified(user))
                {
                    akaDescBuilder.Append(" *(Not Verified)*");
                }

                akaDescBuilder.AppendLine();
            }

            if (index > 1)
            {
                EmbedBuilder builder = new EmbedBuilder();
                builder.Description = akaDescBuilder.ToString();
                builder.Title       = "Also known as:";
                await message.Channel.SendMessageAsync(null, false, builder.Build());
            }
        }