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

Commit

Permalink
Merge branch 'master' into feature/Add-Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Peekaey authored Aug 20, 2024
2 parents be55b98 + 14a1260 commit efd6e6e
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 4 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Qodana
on:
workflow_dispatch:
pull_request:
push:
branches: # Specify your branches here
- main # The 'main' branch
- master # The 'master' branch
- 'releases/*' # The release branches

jobs:
qodana:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
checks: write
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
fetch-depth: 0 # a full history is required for pull request analysis
- name: 'Qodana Scan'
uses: JetBrains/[email protected]
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# TrustTea Bot
### A Discord bot for The FF14 Tea House FC Discord server

#### Built with [Bun](https://bun.sh), [Typescript](https://www.typescriptlang.org/), and [Discord.js](https://discord.js.org/)
#### Built with [Bun](https://bun.sh), [Typescript](https://www.typescriptlang.org/), and [Discord.js](https://discord.js.org/)

This bot is a work in progress and is being developed for the FF14 Tea House FC Discord server. It is not intended for general use as of yet.

Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"typescript": "^5.0.0"
},
"dependencies": {
"axios": "^1.7.3",
"cheerio": "^1.0.0",
"discord-api-types": "^0.37.93",
"discord.js": "^14.15.3",
"dotenv": "^16.4.5",
Expand Down
47 changes: 47 additions & 0 deletions src/Commands/GetCharacterId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import {CommandInteraction, Client, ApplicationCommandOptionType} from "discord.js";
import {Command} from "../Handler/CommandList.ts";
import axios from "axios";
import {GetLodestoneCharacterId, GetLodestoneFreeCompany} from "../Helpers/LodestoneHelpers.ts";

export const GetCharacterId: Command = {
name: "getcharacterid",
description: "Primitively searches the Lodestone for a character and returns the character Id",
options: [
{
name: "message",
description: "Player in-game Username",
type: ApplicationCommandOptionType.String,
required: true
}
],
// run function to execute the command
run: async (client: Client, interaction: CommandInteraction) => {
let messageContent = interaction.options.get("message")!.value as string;

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

if (!firstName && lastName) {
content = "Unable to get entered FirstName and LastName";
} else {
let characterId = await GetLodestoneCharacterId(firstName, lastName);
if (characterId) {
content = characterId;
} else {
content = "Unable to get Character Id";
}
}
} catch (err) {
console.error("Error:", err);
content = `Error: ${err}`;
}

await interaction.followUp({
ephemeral: true,
content
});
}
};
5 changes: 4 additions & 1 deletion src/Handler/CommandList.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Ping } from "../Commands/Ping";
import { CommandInteraction, ChatInputApplicationCommandData, Client } from "discord.js";
import {GetCharacterFreeCompany} from "../Commands/GetCharacterFreeCompany.ts";
import {GetCharacterId} from "../Commands/GetCharacterId.ts";
import {CheckCharacterFreeCompany} from "../Commands/CheckCharacterFreeCompany.ts";

// Typescript Interface for Commands Array
// Run is a function that takes the client and interaction as parameters
Expand All @@ -8,7 +11,7 @@ export interface Command extends ChatInputApplicationCommandData {
}

//Commands Array: Add new commands by importing the command from the files in the commands folder then add to below array
export const Commands: Command[] = [Ping];
export const Commands: Command[] = [Ping, GetCharacterFreeCompany, GetCharacterId, CheckCharacterFreeCompany];



6 changes: 4 additions & 2 deletions src/Helpers/LodestoneHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ export const RobustlyCheckLodestoneFreeCompany = async (firstName: string, lastN
} else {
try {
const content = await GetWebContent(firstName, lastName);

Check warning on line 23 in src/Helpers/LodestoneHelpers.ts

View workflow job for this annotation

GitHub Actions / Qodana for JS

Unused assignment

Variable might not have been initialized

if (!content) {
return "Error Getting Initial Web Content";
} else {
let webContent = cheerio.load(content);
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";
Expand Down

0 comments on commit efd6e6e

Please sign in to comment.