Skip to content

Commit

Permalink
remove more traces of Nova
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen3H committed Jul 31, 2024
1 parent b3b298b commit fd6e298
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 55 deletions.
2 changes: 1 addition & 1 deletion aurora/commands/alliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ async function sendSingleAlliance(
const leaders = [...leaderSet]
const leadersStr = leaders.length > 0 ? leaders.join(", ") : "None"

const allianceEmbed = new CustomEmbed(client, `(Aurora) Alliance Info | ${getName(foundAlliance)}${rank}`)
const allianceEmbed = new CustomEmbed(client, `Alliance Info | ${getName(foundAlliance)}${rank}`)
.addFields(
embedField("Leader(s)", leadersStr, false),
embedField("Type", backtick(allianceType), true),
Expand Down
4 changes: 2 additions & 2 deletions aurora/common/alliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { Client } from "discord.js"
import { Colors } from "discord.js"

class AllianceHelper extends BaseHelper {
constructor(client: Client, isNova = false) {
super(client, isNova)
constructor(client: Client) {
super(client)
this.embed.setColor(Colors.DarkBlue)
}

Expand Down
6 changes: 3 additions & 3 deletions aurora/common/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import type { Client } from 'discord.js'

class BaseHelper {
client: Client = null
isNova = false
//isNova = false

embed = new EmbedBuilder()

constructor(client: Client, isNova: boolean) {
constructor(client: Client) {
this.embed.setFooter(fn.devsFooter(client)).setTimestamp()
this.isNova = isNova
//this.isNova = isNova
}

addField(name: string, value: string, inline = false) {
Expand Down
4 changes: 2 additions & 2 deletions aurora/common/nation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { Client } from "discord.js"
import { Colors } from "discord.js"

class NationHelper extends BaseHelper {
constructor(client: Client, isNova = false) {
super(client, isNova)
constructor(client: Client) {
super(client)
this.embed.setColor(Colors.Orange)
}

Expand Down
54 changes: 26 additions & 28 deletions aurora/common/resident.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as database from '../../bot/utils/database.js'

import {
OfficialAPI,
Nova, Aurora,
Aurora,
type Resident
} from 'earthmc'

Expand Down Expand Up @@ -40,14 +40,14 @@ class ResidentHelper extends BaseHelper {
mcProfile: MCSessionProfile = null
status: "Online" | "Offline"

constructor(client: Client, isNova = false) {
super(client, isNova)
constructor(client: Client) {
super(client)
this.embed.setColor('#A405BA')
}

async fetchResidents(): Promise<Resident[]> {
const arr = await (this.isNova ? database.Nova : database.Aurora).getResidents()
return arr ? arr : await (this.isNova ? Nova : Aurora).Residents.all()
async fetchResidents() {
const arr = await database.Aurora.getResidents()
return arr ? arr : await Aurora.Residents.all()
}

async init(input: string) {
Expand All @@ -59,36 +59,34 @@ class ResidentHelper extends BaseHelper {
this.dbResident = residents.find(r => r.name.toLowerCase() == arg1)

const resName = this.dbResident?.name || arg1
const ops = await (this.isNova ? Nova : Aurora).Players.online()
const ops = await Aurora.Players.online()

const searchName = !this.dbResident ? arg1 : resName
if (ops) this.onlinePlayer = ops.find(p => p.name.toLowerCase() == searchName)

if (!this.isNova) {
let res: V3Player
try {
const arr = await request(`https://api.earthmc.net/v3/aurora/players?query=${arg1}`).then(res => res.body.json()) as V3Player[]
res = arr[0]
} catch (e) {
console.log(e)
return false
}

if (res.town?.uuid) {
const resTown = await OfficialAPI.V2.town(res.town.name.toLowerCase())
let res: V3Player
try {
const arr = await request(`https://api.earthmc.net/v3/aurora/players?query=${arg1}`).then(res => res.body.json()) as V3Player[]
res = arr[0]
} catch (e) {
console.log(e)
return false
}

let rank = resTown.mayor == res.name ? "Mayor" : "Resident"
if (rank == "Mayor" && resTown.status.isCapital)
rank = "Nation Leader"
if (res.town?.uuid) {
const resTown = await OfficialAPI.V2.town(res.town.name.toLowerCase())

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

this.#apiResident = res
res['rank'] = rank
}

this.#apiResident = res

this.status = this.onlinePlayer ? "Online" : "Offline"
this.pInfo = await database.getPlayerInfo(resName, this.isNova).catch(e => console.log(`Database error!\n${e}`))
this.pInfo = await database.getPlayerInfo(resName).catch(e => console.log(`Database error!\n${e}`))

this.tryAddAvatar()

Expand All @@ -111,7 +109,7 @@ class ResidentHelper extends BaseHelper {
nation: (res.nation?.name ?? res.nation) ?? res.townNation
}

this.embed.setTitle(`(${this.isNova ? 'Nova' : 'Aurora'}) Resident Info | \`${res.name}\``)
this.embed.setTitle(`Resident Info | \`${res.name}\``)

if (res.about) {
this.embed.setDescription(`*${res.about}*`)
Expand All @@ -128,7 +126,7 @@ class ResidentHelper extends BaseHelper {
// TODO: mcProfile could be null, handle this case.
//const formattedPlayerName = this.mcProfile.name.replace(/_/g, "\\_")

this.embed.setTitle(`(${this.isNova ? 'Nova' : 'Aurora'}) Player Info | \`${this.mcProfile.name}\``)
this.embed.setTitle(`Player Info | \`${this.mcProfile.name}\``)
this.addField("Affiliation", "No Town", true)

this.addCommonFields()
Expand Down
4 changes: 2 additions & 2 deletions aurora/common/town.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { Client } from "discord.js"
import { Colors } from "discord.js"

class TownHelper extends BaseHelper {
constructor(client: Client, isNova = false) {
super(client, isNova)
constructor(client: Client) {
super(client)
this.embed.setColor(Colors.Green)
}

Expand Down
8 changes: 3 additions & 5 deletions aurora/common/voteparty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ export class VPHelper extends BaseHelper {
return this.#current
}

constructor(client: Client, isNova = false) {
super(client, isNova)

// Pastel pink
this.embed.setColor("#fcb8f7")
constructor(client: Client) {
super(client)
this.embed.setColor("#fcb8f7") // Pastel pink
}

async init() {
Expand Down
4 changes: 2 additions & 2 deletions aurora/slashcommands/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default {
if (!zoom) {
const mapUrl = Aurora.buildMapLink({ x: xCoord, z: zCoord })
return interaction.reply({embeds: [
embed(client, `(Aurora) Location Info`, Colors.Green)
embed(client, `Location Info`, Colors.Green)
.addFields(
embedField("Coordinates (X, Z)", `X: \`${numX}\`\nZ: \`${numZ}\``, true),
embedField("Map Link", `[Click to open](${mapUrl.toString()})`)
Expand All @@ -53,7 +53,7 @@ export default {

const mapUrl = Aurora.buildMapLink({ x: numX, z: numZ }, zoom)
return interaction.reply({embeds: [
embed(client, `(Aurora) Location Info`, Colors.Green)
embed(client, `Location Info`, Colors.Green)
.addFields(
embedField("Coordinates (X, Z)", `X: \`${numX}\`\nZ: \`${numZ}\``, true),
embedField("Zoom", `\`${zoom}\`x`, true),
Expand Down
11 changes: 3 additions & 8 deletions aurora/slashcommands/nationset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ export default {
run: async (_: Client, interaction: ChatInputCommandInteraction) => {
await interaction.deferReply()

const mapDB = interaction.options.getString("map").toLowerCase() == "nova" ? database.Nova : database.Aurora
const nations = (await mapDB.getNations()).map(n => {
const nations = await database.Aurora.getNations().then(arr => arr.map(n => {
n.name = emc.formatString(n.name, true)
return n
})
}))

const nationName = interaction.options.getString("name").toLowerCase()

Expand Down Expand Up @@ -54,7 +53,7 @@ export default {

const save = (n: any) => {
nations[nationIndex] = n
mapDB.setNations(nations)
database.Aurora.setNations(nations)
}

switch (interaction.options.getString("type").toLowerCase()) {
Expand Down Expand Up @@ -128,10 +127,6 @@ export default {
}
}, data: new SlashCommandBuilder().setName("nationset")
.setDescription(desc)
.addStringOption(option => option.setName("map")
.setDescription("Name of the map this nation is in, defaults to Aurora.")
.setRequired(true)
)
.addStringOption(option => option.setName("name")
.setDescription("The name of your nation.")
.setRequired(true)
Expand Down
3 changes: 1 addition & 2 deletions aurora/slashcommands/subscribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ export default {
.setColor(Colors.DarkPurple)
.setTimestamp()

await interaction.channel.send({ embeds: [embed.setTitle("Live Townless Players (Nova)")] })
await interaction.channel.send({ embeds: [embed.setTitle("Live Townless Players (Aurora)")] })
await interaction.channel.send({ embeds: [embed.setTitle("Live Townless Players")] })

await townlessSubbedChannels.update({ channelIDs: FieldValue.arrayUnion(channelID) })
townlessSubbedChannelArray.push(channelID)
Expand Down

0 comments on commit fd6e298

Please sign in to comment.