mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
feat: implemented psa system
This commit is contained in:
1 parent
f6480ad66f
commit
5e98bc988c
19 files changed
+40
-21
No files matched your search
+1
-1
@@ -6,7 +6,7 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "yarn build --dev && yarn start",
|
||||
"start": "node --enable-source-maps dist/index.cjs",
|
||||
"start": "node --enable-source-maps --trace-warnings dist/index.cjs",
|
||||
"zip": "zip -r dist.zip dist",
|
||||
"build": "node scripts/build",
|
||||
"lint": "tsc"
|
||||
|
||||
@@ -13,7 +13,7 @@ const executionStart = new Date().getTime();
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: true,
|
||||
inDevelopment: false,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -26,7 +26,7 @@ export const SKILLED_CLANS: Record<SkilledClan, string> = {
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: true,
|
||||
inDevelopment: false,
|
||||
inPublic: false,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -11,7 +11,7 @@ import { client } from '../index.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: true,
|
||||
inDevelopment: false,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -19,7 +19,7 @@ const DEFAULT_THRESHOLD = 7;
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: true,
|
||||
inDevelopment: false,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -40,7 +40,7 @@ const COMP_TANKS = [
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: true,
|
||||
inDevelopment: false,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -17,7 +17,7 @@ type SortBy = 'name' | 'count';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: true,
|
||||
inDevelopment: false,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -13,7 +13,7 @@ import { AccountInfo } from '../types/accountInfo.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: true,
|
||||
inDevelopment: false,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -12,7 +12,7 @@ import { ClanList } from '../types/clanList.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: true,
|
||||
inDevelopment: false,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -13,7 +13,7 @@ import { AccountList } from '../types/accountList.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: true,
|
||||
inDevelopment: false,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -9,7 +9,7 @@ import { CommandRegistry } from '../events/interactionCreate.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: true,
|
||||
inDevelopment: false,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -35,7 +35,7 @@ import { PlayerClanData } from '../types/playerClanData.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: true,
|
||||
inDevelopment: false,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -35,7 +35,7 @@ import { AccountInfo, AllStats } from '../types/accountInfo.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: true,
|
||||
inDevelopment: false,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -27,7 +27,7 @@ import { PlayerClanData } from '../types/playerClanData.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: true,
|
||||
inDevelopment: false,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -15,7 +15,7 @@ import { PlayerClanData } from '../types/playerClanData.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: true,
|
||||
inDevelopment: false,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export const ACCENT_COLOR = '#ecedee'; // theme.colors.textHighContrast
|
||||
export const ACCENT_COLOR = '#ecedee';
|
||||
export const POSITIVE_COLOR = '#82ff29';
|
||||
export const NEGATIVE_COLOR = '#ff4747';
|
||||
export const WARNING_COLOR = '#ffab00';
|
||||
@@ -0,0 +1,9 @@
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
import { WARNING_COLOR } from '../../constants/colors.js';
|
||||
|
||||
export default function warningEmbed(title: string, description: string) {
|
||||
return new EmbedBuilder()
|
||||
.setColor(WARNING_COLOR)
|
||||
.setTitle(title)
|
||||
.setDescription(description);
|
||||
}
|
||||
@@ -12,9 +12,9 @@ export const psa: PSA = {};
|
||||
console.log('Caching PSA...');
|
||||
fetch(
|
||||
'https://gist.githubusercontent.com/tresabhi/ed4b136f08856e615212e573aabe1968/raw',
|
||||
).then((response) => {
|
||||
response.json().then((data) => {
|
||||
)
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
psa.data = data as PSAData;
|
||||
console.log('PSA cached');
|
||||
});
|
||||
console.log('PSA cached');
|
||||
});
|
||||
@@ -29,9 +29,11 @@ import tankstats from '../commands/tankstats.js';
|
||||
import today from '../commands/today.js';
|
||||
import verify from '../commands/verify.js';
|
||||
import negativeEmbed from '../core/interaction/negativeEmbed.js';
|
||||
import warningEmbed from '../core/interaction/warningEmbed.js';
|
||||
import { DISCORD_TOKEN } from '../core/process/args.js';
|
||||
import getClientId from '../core/process/getClientId.js';
|
||||
import isDev from '../core/process/isDev.js';
|
||||
import { psa } from '../core/process/psa.js';
|
||||
import render from '../core/ui/render.js';
|
||||
import { handleError } from './error.js';
|
||||
|
||||
@@ -149,10 +151,17 @@ export default async function interactionCreate(
|
||||
|
||||
try {
|
||||
const result = await command.execute(interaction);
|
||||
const normalizedResult = Array.isArray(result) ? result : [result];
|
||||
const reply: InteractionEditReplyOptions = {};
|
||||
|
||||
if (psa.data) {
|
||||
normalizedResult.push(
|
||||
warningEmbed(psa.data.title, psa.data.description),
|
||||
);
|
||||
}
|
||||
|
||||
await Promise.all(
|
||||
(Array.isArray(result) ? result : [result]).map(async (item) => {
|
||||
normalizedResult.map(async (item) => {
|
||||
if (item instanceof EmbedBuilder) {
|
||||
if (!reply.embeds) reply.embeds = [];
|
||||
reply.embeds.push(item);
|
||||
|
||||
Reference in new issue
Block a user