Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7,405 changes: 212 additions & 7,193 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"cron": "^4.1.0",
"dayjs": "^1.11.13",
"decache": "^4.6.2",
"discord.js": "^13.17.1",
"discord.js": "^14.17.3",
"flat-cache": "^3.2.0",
"i18n-string-templates": "^1.0.7",
"json-query": "^2.2.2",
Expand Down
53 changes: 23 additions & 30 deletions src/bot.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import Discord from 'discord.js';
import { Client, WebhookClient, GatewayIntentBits, Events, PresenceUpdateStatus } from 'discord.js';

import WorldStateClient from './utilities/WorldStateClient.js';
import EventHandler from './eventHandlers/EventHandler.js';
import Database from './settings/Database.js';
import logger from './utilities/Logger.js';

const {
Client,
WebhookClient,
Intents,
Constants: { Events },
} = Discord;

const unlog = {
debug: ['WS_CONNECTION_TIMEOUT'],
error: /^(Unknown Message)/gi,
Expand Down Expand Up @@ -59,7 +52,7 @@ export default class Genesis {
shards,
shardCount: Number(process.env.SHARDS || 1),
presence: {
status: 'dnd',
status: PresenceUpdateStatus.DoNotDisturb,
afk: false,
activities: [
{
Expand All @@ -68,11 +61,11 @@ export default class Genesis {
],
},
intents: [
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_INTEGRATIONS,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
Intents.FLAGS.GUILD_VOICE_STATES,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildIntegrations,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildVoiceStates,
],
});

Expand Down Expand Up @@ -148,35 +141,35 @@ export default class Genesis {
}

async setupHandlers() {
this.client.on(Events.CLIENT_READY, async () =>
this.eventHandler.handleEvent({ event: Events.CLIENT_READY, args: [] })
this.client.on(Events.ClientReady, async () =>
this.eventHandler.handleEvent({ event: Events.ClientReady, args: [] })
);

this.client.on(Events.GUILD_CREATE, async (guild) =>
this.eventHandler.handleEvent({ event: Events.GUILD_CREATE, args: [guild] })
this.client.on(Events.GuildCreate, async (guild) =>
this.eventHandler.handleEvent({ event: Events.GuildCreate, args: [guild] })
);
this.client.on(Events.GUILD_DELETE, async (guild) =>
this.eventHandler.handleEvent({ event: Events.GUILD_DELETE, args: [guild] })
this.client.on(Events.GuildDelete, async (guild) =>
this.eventHandler.handleEvent({ event: Events.GuildDelete, args: [guild] })
);
this.client.on(Events.CHANNEL_CREATE, async (channel) =>
this.eventHandler.handleEvent({ event: Events.CHANNEL_CREATE, args: [channel] })
this.client.on(Events.ChannelCreate, async (channel) =>
this.eventHandler.handleEvent({ event: Events.ChannelCreate, args: [channel] })
);
this.client.on(Events.CHANNEL_DELETE, async (channel) =>
this.eventHandler.handleEvent({ event: Events.CHANNEL_DELETE, args: [channel] })
this.client.on(Events.ChannelDelete, async (channel) =>
this.eventHandler.handleEvent({ event: Events.ChannelDelete, args: [channel] })
);

this.client.on(Events.INTERACTION_CREATE, async (interaction) =>
this.eventHandler.handleEvent({ event: Events.INTERACTION_CREATE, args: [interaction] })
this.client.on(Events.InteractionCreate, async (interaction) =>
this.eventHandler.handleEvent({ event: Events.InteractionCreate, args: [interaction] })
);

this.client.on(Events.SHARD_DISCONNECT, (event) => {
this.client.on(Events.ShardDisconnect, (event) => {
this.logger.error(`Disconnected with close event: ${event.code}`);
});
this.client.on(Events.ERROR, (error) => {
this.client.on(Events.Error, (error) => {
if (!unlog.error.test(error.message)) this.logger.error(error);
});
this.client.on(Events.WARN, this.logger.warn);
this.client.on(Events.DEBUG, (message) => {
this.client.on(Events.Warn, this.logger.warn);
this.client.on(Events.Debug, (message) => {
if (/(heartbeat|Latency of|voice|HELLO timeout|CONNECT|Spawning)/i.test(message)) {
this.logger.silly(message);
return;
Expand Down
34 changes: 17 additions & 17 deletions src/embeds/AcolyteEmbed.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,36 @@ export default class AcolyteEmbed extends BaseEmbed {
constructor(enemies, { platform, i18n, locale }) {
super(locale);

this.thumbnail = {
url: acolyteThumb,
};
this.title = i18n`[${platform.toUpperCase()}] Acolytes`;
this.setThumbnail(acolyteThumb);
this.setTitle(i18n`[${platform.toUpperCase()}] Acolytes`);
if (Array.isArray(enemies) && enemies.length > 1) {
this.color = enemies.length > 2 ? 0x00ff00 : 0xff0000;
this.fields = enemies.map((e) => ({
name: e.agentType,
value: i18n`Last discovered at ${e.lastDiscoveredAt}.
this.setColor(enemies.length > 2 ? 0x00ff00 : 0xff0000);
this.setFields(
enemies.map((e) => ({
name: e.agentType,
value: i18n`Last discovered at ${e.lastDiscoveredAt}.
It has ${(100 * Number(e.healthPercent)).toFixed(2)}% health remaining
and is currently ${e.isDiscovered ? 'discovered' : 'not discovered'}`,
}));
}))
);
} else if (!Array.isArray(enemies) || enemies.length === 1) {
const e = Array.isArray(enemies) ? enemies[0] : enemies;
this.title = i18n`[${platform.toUpperCase()}] ${e.agentType}`;
this.description = i18n`Enemy ${e.isDiscovered ? i18n`Discovered` : i18n`Hiding`}!`;
this.color = 0xaf5b4b;
this.fields = [
this.setTitle(i18n`[${platform.toUpperCase()}] ${e.agentType}`);
this.setDescription(i18n`Enemy ${e.isDiscovered ? i18n`Discovered` : i18n`Hiding`}!`);
this.setColor(0xaf5b4b);
this.setFields([
{ name: '\u200B', value: `**${e.isDiscovered ? '' : 'Last '}Discovered At:** ${e.lastDiscoveredAt}` },
{ name: '\u200B', value: `**Health Remaining:** ${(100 * Number(e.healthPercent)).toFixed(2)}%` },
{ name: '\u200B', value: `Will flee after ${e.fleeDamage} damage.\nGet after the Acolyte, Tenno!` },
];
]);
} else {
this.color = 0xaf5b4b;
this.fields = [
this.setColor(0xaf5b4b);
this.setFields([
{
name: i18n`There are currently no enemies to combat`,
value: '\u200B',
},
];
]);
}
}
}
48 changes: 24 additions & 24 deletions src/embeds/AlertEmbed.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,50 +15,50 @@ export default class AlertEmbed extends BaseEmbed {
constructor(alerts, { platform, i18n, locale }) {
super(locale);

this.thumbnail = {
url: alertThumb,
};
this.color = 0xf1c40f;
this.setThumbnail(alertThumb);
this.setColor(0xf1c40f);
// compact
if (Array.isArray(alerts) && alerts.length > 1) {
this.fields = alerts.map((a) => ({
name: i18n`${a.mission.reward.asString} | ${a.eta} left`,
value: i18n`${a.mission.faction} ${a.mission.type} on ${a.mission.node}\nlevel ${a.mission.minEnemyLevel} - ${a.mission.maxEnemyLevel}\n\u200B`,
}));
this.title = i18n`[${platform.toUpperCase()}] Worldstate - Alerts`;
this.setFields(
alerts.map((a) => ({
name: i18n`${a.mission.reward.asString} | ${a.eta} left`,
value: i18n`${a.mission.faction} ${a.mission.type} on ${a.mission.node}\nlevel ${a.mission.minEnemyLevel} - ${a.mission.maxEnemyLevel}\n\u200B`,
}))
);
this.setTitle(i18n`[${platform.toUpperCase()}] Worldstate - Alerts`);
} else {
// divided
const a = Array.isArray(alerts) ? alerts[0] : alerts;
this.title = i18n`[${platform.toUpperCase()}] ${
a.mission.reward.itemString || i18n`${a.mission.reward.credits} Credits`
}`;
this.color = a.mission.reward.color;
this.thumbnail.url = a.mission.reward.thumbnail;
this.setTitle(
i18n`[${platform.toUpperCase()}] ${a.mission.reward.itemString || i18n`${a.mission.reward.credits} Credits`}`
);
this.setColor(a.mission.reward.color);
this.setThumbnail(a.mission.reward.thumbnail);
const summary = i18n`${a.mission.faction} ${a.mission.type} on ${a.mission.node}`;
this.description = a.description;
this.setDescription(a.description);

this.fields = [];
this.setFields([]);
if (this.description !== summary) {
this.fields.push({ name: i18n`Mission`, value: i18n`${a.mission.faction} ${a.mission.type}`, inline: true });
this.fields.push({ name: i18n`Location`, value: a.mission.node, inline: true });
this.addFields([{ name: i18n`Mission`, value: i18n`${a.mission.faction} ${a.mission.type}`, inline: true }]);
this.addFields([{ name: i18n`Location`, value: a.mission.node, inline: true }]);
}
this.fields.push({
this.addFields({
name: 'Levels:',
value: `${a.mission.minEnemyLevel} - ${a.mission.maxEnemyLevel}`,
inline: true,
});

this.fields.push({
this.addFields({
name: i18n`Archwing Required`,
value: a.mission.archwingRequired ? i18n`Yes` : i18n`No`,
inline: true,
});

if (this.title.indexOf('Cr') === -1) {
this.fields.push({ name: '\u200B', value: i18n`**Credits:** ${a.mission.reward.credits}`, inline: true });
if (this.data.title.indexOf('Cr') === -1) {
this.addFields({ name: '\u200B', value: i18n`**Credits:** ${a.mission.reward.credits}`, inline: true });
}
this.footer.text = i18n`${a.eta} remaining • Expires `;
this.timestamp = a.expiry;
this.setFooter({ text: i18n`${a.eta} remaining • Expires ` });
this.setTimestamp(a.expiry);
}
}
}
20 changes: 11 additions & 9 deletions src/embeds/ArbitrationEmbed.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ export default class ArbitrationEmbed extends BaseEmbed {
*/
constructor(arbitration, { platform, i18n, locale }) {
super(locale);
this.thumbnail.url = arbiThumb;
this.color = 0x742725;
this.title = i18n`[${platform.toUpperCase()}] Worldstate - Arbitration`;
this.fields.push({
name: arbitration.node || '???',
value: arbitration.type || '???',
});
this.footer.text = i18n`Expires`;
this.timestamp = arbitration.expiry;
this.setThumbnail(arbiThumb);
this.setColor(0x742725);
this.setTitle(i18n`[${platform.toUpperCase()}] Worldstate - Arbitration`);
this.addFields([
{
name: arbitration.node || '???',
value: arbitration.type || '???',
},
]);
this.setFooter({ text: i18n`Expires` });
this.setTimestamp(arbitration.expiry);
}
}
4 changes: 2 additions & 2 deletions src/embeds/BaseEmbed.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MessageEmbed } from 'discord.js';
import { EmbedBuilder } from 'discord.js';

const defaults = {
url: process.env.EMBED_URL || 'https://warframestat.us',
Expand All @@ -8,7 +8,7 @@ const defaults = {
/**
* Utility class for making rich embeds
*/
export default class BaseEmbed extends MessageEmbed {
export default class BaseEmbed extends EmbedBuilder {
constructor(locale) {
super({
url: defaults.url,
Expand Down
18 changes: 10 additions & 8 deletions src/embeds/BuildEmbed.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,24 @@ export default class BuildEmbed extends BaseEmbed {
constructor(build) {
super();
const sections = build.body.split(';');
this.color = 0xf1c40f;
this.title = build.title;
this.fields = [];
this.setColor(0xf1c40f);
this.setTitle(build.title);
this.setFields([]);
sections.forEach((value, index) => {
if (index === 0) {
this.description = value;
this.setDescription(value);
} else {
this.addFields({
name: '\u200B',
value,
});
}
});
this.image = { url: build.url || build.image };
this.footer.text = `${build.id}${build.isPublic ? ' • Public' : ''} • Owned by ${
typeof build.owner === 'object' ? build.owner.tag : build.owner
}`;
this.setImage({ url: build.url || build.image });
this.setFooter({
text: `${build.id}${build.isPublic ? ' • Public' : ''} • Owned by ${
typeof build.owner === 'object' ? build.owner.tag : build.owner
}`,
});
}
}
14 changes: 6 additions & 8 deletions src/embeds/CambionEmbed.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,16 @@ export default class CambionEmbed extends BaseEmbed {
*/
constructor(state, { i18n, locale }) {
super(locale);
this.title = i18n`Cambion Drift Cycle - ${toTitleCase(state.active)}`;
this.color = state.active === 'fass' ? 0xc6733f : 0x415b9e;
this.thumbnail = {
url: state.active === 'fass' ? fass : vome,
};
this.setTitle(i18n`Cambion Drift Cycle - ${toTitleCase(state.active)}`);
this.setColor(state.active === 'fass' ? 0xc6733f : 0x415b9e);
this.setThumbnail(state.active === 'fass' ? fass : vome);

const next = toTitleCase(state.active === 'fass' ? 'vome' : 'fass');

const nextCtd = i18n`Time remaining until ${next}: ${rTime(state.expiry)}`;
this.description = `${state.bounty ? makeJobs(state.bounty, i18n) : ''}\n\n${nextCtd}`;
this.setDescription(`${state.bounty ? makeJobs(state.bounty, i18n) : ''}\n\n${nextCtd}`);

this.footer.text = i18n`${next} starts `;
this.timestamp = new Date(state.expiry).getTime();
this.setFooter({ text: i18n`${next} starts ` });
this.setTimestamp(new Date(state.expiry).getTime());
}
}
6 changes: 3 additions & 3 deletions src/embeds/CompanionEmbed.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class CompanionEmbed extends BaseEmbed {
.setURL(`https://warframe.fandom.com/wiki/${companion.name.replace(/\s/g, '_')}`)
.setThumbnail(`https://cdn.warframestat.us/img/${companion.imageName}`)
.setDescription(companion.description)
.addFields(
.addFields([
{ name: i18n`Health`, value: `${companion.health}`, inline: true },
{ name: i18n`Power`, value: `${companion.power}`, inline: true },
{ name: i18n`Armor`, value: `${companion.armor}`, inline: true },
Expand All @@ -25,7 +25,7 @@ export default class CompanionEmbed extends BaseEmbed {
inline: true,
},
{ name: `Build Price`, value: `${companion.buildPrice}${emojify('credits')}`, inline: true },
{ name: `Build Skip`, value: `${companion.skipBuildTimePrice}${emojify('p')}`, inline: true }
);
{ name: `Build Skip`, value: `${companion.skipBuildTimePrice}${emojify('p')}`, inline: true },
]);
}
}
30 changes: 16 additions & 14 deletions src/embeds/ComponentEmbed.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@ import BaseEmbed from './BaseEmbed.js';
export default class ComponentEmbed extends BaseEmbed {
constructor(components, { i18n, locale }) {
super(locale);
this.title = 'Components';
this.color = 0xd3d3d3;
this.fields = components.map((component) => {
const tokens = [];
tokens.push(`_${component.description}_\n`);
tokens.push(component.itemCount ? i18n`**#:** ${component.itemCount}\n` : '');
tokens.push(component.ducats ? i18n`**Ducats:** ${component.ducats}\n` : '');
tokens.push(i18n`**Tradable:** ${component.ducats ? i18n`Yes` : i18n`No`}`);
tokens.push('\n\u200B\n');
return {
name: component.name,
value: tokens.join(''),
};
});
this.setTitle('Components');
this.setColor(0xd3d3d3);
this.setFields(
components.map((component) => {
const tokens = [];
tokens.push(`_${component.description}_\n`);
tokens.push(component.itemCount ? i18n`**#:** ${component.itemCount}\n` : '');
tokens.push(component.ducats ? i18n`**Ducats:** ${component.ducats}\n` : '');
tokens.push(i18n`**Tradable:** ${component.ducats ? i18n`Yes` : i18n`No`}`);
tokens.push('\n\u200B\n');
return {
name: component.name,
value: tokens.join(''),
};
})
);
}
}
Loading