Skip to content

Commit

Permalink
b
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen3H committed Jun 25, 2024
1 parent ae77a32 commit 74b68a6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
15 changes: 8 additions & 7 deletions aurora/slashcommands/nation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as fn from '../../bot/utils/fn.js'
import * as emc from "earthmc"
import * as database from "../../bot/utils/database.js"

import {
Expand All @@ -13,6 +12,8 @@ import {
import { CustomEmbed, EntityType } from "../../bot/objects/CustomEmbed.js"
import News from "../../bot/objects/News.js"

import { Aurora, NotFoundError } from 'earthmc'

export default {
name: "nation",
description: "Displays info for a nation.",
Expand All @@ -34,7 +35,7 @@ export default {
const nationsWithoutDuplicates = []

let nations = await database.Aurora.getNations()
if (!nations) nations = await emc.Aurora.Nations.all().catch(err => console.log(err))
if (!nations) nations = await Aurora.Nations.all().catch(err => console.log(err))

if (subCmd == "list") {
let comparator = interaction.options.getString("comparator")
Expand All @@ -43,12 +44,12 @@ export default {
comparator = comparator.toLowerCase()

if (comparator == "online") {
const onlinePlayers = await emc.Aurora.Players.online().catch(() => {})
const onlinePlayers = await Aurora.Players.online().catch(() => {})
if (!onlinePlayers) return await interaction.editReply({embeds: [fn.fetchError]})
.then(() => setTimeout(() => interaction.deleteReply(), 10000)).catch(() => {})

let towns = await database.Aurora.getTowns()
if (!towns) towns = await emc.Aurora.Towns.all()
if (!towns) towns = await Aurora.Towns.all()

const len = towns.length
for (let i = 0; i < len; i++) {
Expand Down Expand Up @@ -209,8 +210,8 @@ export default {
return interaction.editReply({embeds: [nationEmbed]})
}

const capitalColours = await emc.Aurora.Towns.get(nation.capital.name).then((t: any) => {
return t instanceof emc.NotFoundError ? null : t.colourCodes
const capitalColours = await Aurora.Towns.get(nation.capital.name).then((t: any) => {
return t instanceof NotFoundError ? null : t.colourCodes
})

const colour = capitalColours ? parseInt(capitalColours.fill.replace('#', '0x')) : Colors.Aqua
Expand Down Expand Up @@ -260,7 +261,7 @@ export default {
if (nation.discord)
nationEmbed.setURL(nation.discord)

const onlinePlayers = await emc.Aurora.Players.online().catch(() => {})
const onlinePlayers = await Aurora.Players.online().catch(() => {})
if (onlinePlayers) {
// Filter nation residents by which are online
const onlineNationResidents = fn.removeDuplicates(
Expand Down
6 changes: 3 additions & 3 deletions aurora/slashcommands/resident.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
EmbedBuilder, SlashCommandBuilder, Colors
} from "discord.js"

import * as fn from '../../bot/utils/fn.js'
import { ResidentHelper } from '../../common/resident.js'
import { devsFooter } from "../../bot/utils/fn.js"

export default {
name: "resident",
Expand All @@ -20,7 +20,7 @@ export default {
.setTitle("Invalid Arguments!")
.setDescription("Usage: `/resident playerName`")
.setColor(Colors.Red)
.setFooter(fn.devsFooter(client))
.setFooter(devsFooter(client))
.setTimestamp()
], ephemeral: true })
}
Expand All @@ -33,7 +33,7 @@ export default {
return interaction.followUp({embeds: [new EmbedBuilder()
.setTitle(name + " isn't a registered player name, please try again.")
.setColor(Colors.Red)
.setFooter(fn.devsFooter(client))
.setFooter(devsFooter(client))
.setTimestamp()
], ephemeral: true })
}
Expand Down

0 comments on commit 74b68a6

Please sign in to comment.