Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

Commit

Permalink
Fix Merge Conflict Errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Peekaey committed Aug 20, 2024
1 parent efd6e6e commit fa4e338
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 30 deletions.
4 changes: 2 additions & 2 deletions src/Commands/CheckCharacterFreeCompany.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Command} from "../Handler/CommandList.ts";
import {ApplicationCommandOptionType, Client, CommandInteraction} from "discord.js";
import {GetLodestoneFreeCompany, RobustlyCheckLodestoneFreeCompany} from "../Helpers/LodestoneHelpers.ts";
import {RobustlyCheckLodestoneFreeCompany} from "../Helpers/LodestoneHelpers.ts";

export const CheckCharacterFreeCompany: Command = {
name: "checkcharacterfreecompany",
Expand All @@ -17,7 +17,7 @@ export const CheckCharacterFreeCompany: Command = {
run: async (client: Client, interaction: CommandInteraction) => {
let messageContent = interaction.options.get("message")!.value as string;

let content = "";
let content;
try {
let [firstName, lastName] = messageContent.split(" ");

Expand Down
5 changes: 2 additions & 3 deletions src/Commands/GetCharacterFreeCompany.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {CommandInteraction, Client, ApplicationCommandOptionType} from "discord.js";
import {Command} from "../Handler/CommandList.ts";
import axios from "axios";
import {GetLodestoneCharacterId, GetLodestoneFreeCompany} from "../Helpers/LodestoneHelpers.ts";
import {GetLodestoneFreeCompany} from "../Helpers/LodestoneHelpers.ts";

export const GetCharacterFreeCompany: Command = {
name: "getcharacterfreecompany",
Expand All @@ -18,7 +17,7 @@ export const GetCharacterFreeCompany: Command = {
run: async (client: Client, interaction: CommandInteraction) => {
let messageContent = interaction.options.get("message")!.value as string;

let content = "";
let content;
try {
let [firstName, lastName] = messageContent.split(" ");

Expand Down
5 changes: 2 additions & 3 deletions src/Commands/GetCharacterId.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {CommandInteraction, Client, ApplicationCommandOptionType} from "discord.js";
import {Command} from "../Handler/CommandList.ts";
import axios from "axios";
import {GetLodestoneCharacterId, GetLodestoneFreeCompany} from "../Helpers/LodestoneHelpers.ts";
import {GetLodestoneCharacterId} from "../Helpers/LodestoneHelpers.ts";

export const GetCharacterId: Command = {
name: "getcharacterid",
Expand All @@ -20,7 +19,7 @@ export const GetCharacterId: Command = {

// Default to Carbuncle Server as we only need to query the FCs server location
let server = "Carbuncle";
let content = "";
let content;
try {
let [firstName, lastName] = messageContent.split(" ");

Expand Down
44 changes: 22 additions & 22 deletions src/Helpers/LodestoneHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import axios from "axios";
import * as cheerio from "cheerio";


// Example Query In Browser
// https://na.finalfantasyxiv.com/lodestone/character/?q=Art+Bayard&worldname=Carbuncle&classjob=&race_tribe=&blog_lang=ja&blog_lang=en&blog_lang=de&blog_lang=fr&order=
const baseURL = "https://na.finalfantasyxiv.com/lodestone/character/?q=";
Expand All @@ -24,31 +23,32 @@ export const RobustlyCheckLodestoneFreeCompany = async (firstName: string, lastN
if (!content) {
return "Error Getting Initial Web Content";
} else {
let webContent = cheerio.load(content);
if (!webContent) {
return "Error Getting Initial Web Content";
} else {
let href = webContent('a.entry__link').first().attr('href');
if (!href) {
return "Error Getting Character ID - No Characters were found";
let webContent = cheerio.load(content);
if (!webContent) {
return "Error Getting Initial Web Content";
} else {
let url = href.match(/\/lodestone\/character\/(\d+)\//);
if (!url) {
return "Error Getting Character URL - CSS Selectors For Character URL May Have Changed";
let href = webContent('a.entry__link').first().attr('href');
if (!href) {
return "Error Getting Character ID - No Characters were found";
} else {
let characterId = url[1];
if (!characterId) {
return "Error Parsing Character ID - Character URL May Have Changed";
let url = href.match(/\/lodestone\/character\/(\d+)\//);
if (!url) {
return "Error Getting Character URL - CSS Selectors For Character URL May Have Changed";
} else {
// Found Character ID - Meaning Player Name is Valid and Found
// Now Get Free Company Name
let freeCompany = webContent('a.entry__freecompany__link').first().find('span').text();
if (!freeCompany) {
// Character not in a Free Company or CSS Selector may have updated
return "Character not in a free company or CSS Selector may have updated";
let characterId = url[1];
if (!characterId) {
return "Error Parsing Character ID - Character URL May Have Changed";
} else {
// Free Company Found
return freeCompany;
// Found Character ID - Meaning Player Name is Valid and Found
// Now Get Free Company Name
let freeCompany = webContent('a.entry__freecompany__link').first().find('span').text();
if (!freeCompany) {
// Character not in a Free Company or CSS Selector may have updated
return "Character not in a free company or CSS Selector may have updated";
} else {
// Free Company Found
return freeCompany;
}
}
}
}
Expand Down

0 comments on commit fa4e338

Please sign in to comment.