Skip to content

Commit

Permalink
alliance discordInvite should be in partial
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen3H committed Jul 22, 2024
1 parent 5e2654b commit 943bf32
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 20 deletions.
16 changes: 6 additions & 10 deletions bot/events/interactionCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default {
name: 'interactionCreate',
async execute(interaction: BaseInteraction) {
const client: ExtendedClient = interaction.client
const username = interaction.user.username
const username = interaction.user.displayName

let cmdName: string = null
if (interaction.isCommand())
Expand All @@ -39,17 +39,13 @@ export default {
const cmd = client.slashCommands.get(cmdName)
if (!cmd) return

console.log(`${username} used command: '${cmdName}'`)
console.log(`[${username}] Interaction triggered: '${cmdName}'`)
return await cmd.run(client, interaction).catch(console.error)
}

if (interaction.isUserContextMenuCommand()) {
console.log(`${username} triggered a context menu action.`)

if (cmdName == "Link User") {
console.log('Attempting to link a player')
return await showLinkModal(interaction)
}
console.log(`[${username}] Context menu action triggered: '${cmdName}'`)
if (cmdName == "Link User") return await showLinkModal(interaction)
}

if (interaction.isModalSubmit()) {
Expand All @@ -66,12 +62,12 @@ export default {
const alliance = modal.asObject(interaction)

//#region Send alliance embed preview.
const preview = new CustomEmbed(client, `(${alliance.mapName}) Alliance Preview | ${alliance.allianceName}`)
const preview = new CustomEmbed(client, `(${alliance.map}) Alliance Preview | ${alliance.allianceName}`)
.setColor(Colors.DarkBlue)
.setThumbnail(alliance.imageURL ? alliance.imageURL : 'attachment://aurora.png')
.addButton('creation_extra', 'Extra')
.addButton('creation_finish', 'Finish', ButtonStyle.Success)
.addField("Leader(s)", alliance.leaders.length > 0 ? alliance.leaders : "None", true)
.addField("Leader(s)", alliance.leaderName.length > 0 ? alliance.leaderName : "None", true)

if (alliance.discordInvite != "No discord invite has been set for this alliance")
preview.setURL(alliance.discordInvite)
Expand Down
10 changes: 5 additions & 5 deletions bot/events/messageCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function runCmd(msg: Message, sliceAmt: number, cmdsKey: string) {
const commands = (msg.client as any)[cmdsKey] as Collection<string, MessageCommand>

const command = commands.get(commandName) || commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName))
if (!command) return console.log(`Could not find command '${commandName}'`)
if (!command) return console.log(`[${msg.author.displayName}] Could not find command '${commandName}'`)

const channel = msg.channel
if (channel.type == ChannelType.GuildText) {
Expand Down Expand Up @@ -67,10 +67,10 @@ export default {
if (prefix(message, "/"))
return runCmd(message, 1, 'auroraCommands')

if (prefix(message, "a/"))
return runCmd(message, 2, 'auroraCommands')
// if (prefix(message, "a/"))
// return runCmd(message, 2, 'auroraCommands')

if (prefix(message, "n/"))
return runCmd(message, 2, 'novaCommands')
//if (prefix(message, "n/"))
//return runCmd(message, 2, 'novaCommands')
}
}
9 changes: 5 additions & 4 deletions bot/objects/AllianceModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,20 @@ class AllianceModal extends ModalBuilder {
}

asObject = (interaction: ModalSubmitInteraction) => {
const obj: any = {
mapName: this.alliance.map,
const obj: DBAlliance & { map?: string } = {
map: this.alliance.map,
allianceName: this.alliance.allianceName,
type: this.alliance.type || "normal",
nations: fieldVal(interaction, 'nations').replaceAll(' ', '').split(','),
leaders: fieldVal(interaction, 'leaders')
leaderName: fieldVal(interaction, 'leaders')
}

const fullName = fieldVal(interaction, 'full_name')
const discord = fieldVal(interaction, 'discord')
const flag = fieldVal(interaction, 'flag')

if (fullName) obj.fullName = fullName
if (discord) obj.discord = discord
if (discord) obj.discordInvite = discord
if (flag) obj.imageURL = flag

return obj
Expand Down
2 changes: 1 addition & 1 deletion bot/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ export type AllianceType = 'sub' | 'mega' | 'normal'
export type DBAlliance = {
allianceName: string
leaderName: string
discordInvite: string
type: AllianceType
nations: string[]
} & Partial<{
fullName: string
imageURL: string
discordInvite: string
colours: {
fill: string
outline: string
Expand Down

0 comments on commit 943bf32

Please sign in to comment.