Skip to content

Commit

Permalink
shut djs the fuck up
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen3H committed Oct 13, 2024
1 parent 07691f1 commit f73f890
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
18 changes: 11 additions & 7 deletions aurora/common/resident.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,26 @@ class ResidentHelper extends BaseHelper {
const searchName = !this.dbResident ? arg1 : resName
if (ops) this.onlinePlayer = ops.find(p => p.name.toLowerCase() == searchName)

const res = await OfficialAPI.V3.players().then(arr => arr[0]).catch(e => {
let resident: V3Player
try {
const players = await OfficialAPI.V3.players()
resident = players[0] as V3Player
} catch(e: any) {
console.error(e)
return false
})
}

if (res.town?.uuid) {
const resTown = await OfficialAPI.V2.town(res.town.name.toLowerCase())
if (resident.town?.uuid) {
const resTown = await OfficialAPI.V2.town(resident.town.name.toLowerCase())

let rank = resTown.mayor == res.name ? "Mayor" : "Resident"
let rank = resTown.mayor == resident.name ? "Mayor" : "Resident"
if (rank == "Mayor" && resTown.status.isCapital)
rank = "Nation Leader"

res['rank'] = rank
resident['rank'] = rank
}

this.#apiResident = res
this.#apiResident = resident

this.status = this.onlinePlayer ? "Online" : "Offline"
this.pInfo = await database.getPlayerInfo(resName).catch(e => console.log(`Database error!\n${e}`))
Expand Down
8 changes: 5 additions & 3 deletions bot/utils/fn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import type {
EmojiIdentifierResolvable,
User,
APIEmbedField,
Awaitable
Awaitable,
APIActionRowComponent,
APIMessageActionRowComponent
} from "discord.js"

import {
Expand Down Expand Up @@ -187,14 +189,14 @@ export const paginatorInteraction = async(
paginator(interaction.user.id, msg, embeds, currentPage)
}

function buildButtons(currentPage: number, lastPage: number) {
const buildButtons = (currentPage: number, lastPage: number) => {
const noFurther = currentPage >= lastPage
const noLess = currentPage <= 0

return new ActionRowBuilder<ButtonBuilder>().addComponents(
emojiButton("first", "⏪", noLess), emojiButton("back", "◀", noLess),
emojiButton("forward", "▶", noFurther), emojiButton("last", "⏩", noFurther)
)
).toJSON() as APIActionRowComponent<APIMessageActionRowComponent>
}

const emojiButton = (
Expand Down

0 comments on commit f73f890

Please sign in to comment.