mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +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",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "yarn build --dev && yarn start",
|
"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",
|
"zip": "zip -r dist.zip dist",
|
||||||
"build": "node scripts/build",
|
"build": "node scripts/build",
|
||||||
"lint": "tsc"
|
"lint": "tsc"
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ const executionStart = new Date().getTime();
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: true,
|
inDevelopment: false,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export const SKILLED_CLANS: Record<SkilledClan, string> = {
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: true,
|
inDevelopment: false,
|
||||||
inPublic: false,
|
inPublic: false,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { client } from '../index.js';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: true,
|
inDevelopment: false,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const DEFAULT_THRESHOLD = 7;
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: true,
|
inDevelopment: false,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ const COMP_TANKS = [
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: true,
|
inDevelopment: false,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ type SortBy = 'name' | 'count';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: true,
|
inDevelopment: false,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { AccountInfo } from '../types/accountInfo.js';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: true,
|
inDevelopment: false,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { ClanList } from '../types/clanList.js';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: true,
|
inDevelopment: false,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { AccountList } from '../types/accountList.js';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: true,
|
inDevelopment: false,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { CommandRegistry } from '../events/interactionCreate.js';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: true,
|
inDevelopment: false,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import { PlayerClanData } from '../types/playerClanData.js';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: true,
|
inDevelopment: false,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import { AccountInfo, AllStats } from '../types/accountInfo.js';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: true,
|
inDevelopment: false,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import { PlayerClanData } from '../types/playerClanData.js';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: true,
|
inDevelopment: false,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { PlayerClanData } from '../types/playerClanData.js';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: true,
|
inDevelopment: false,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
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 POSITIVE_COLOR = '#82ff29';
|
||||||
export const NEGATIVE_COLOR = '#ff4747';
|
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...');
|
console.log('Caching PSA...');
|
||||||
fetch(
|
fetch(
|
||||||
'https://gist.githubusercontent.com/tresabhi/ed4b136f08856e615212e573aabe1968/raw',
|
'https://gist.githubusercontent.com/tresabhi/ed4b136f08856e615212e573aabe1968/raw',
|
||||||
).then((response) => {
|
)
|
||||||
response.json().then((data) => {
|
.then((response) => response.json())
|
||||||
|
.then((data) => {
|
||||||
psa.data = data as PSAData;
|
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 today from '../commands/today.js';
|
||||||
import verify from '../commands/verify.js';
|
import verify from '../commands/verify.js';
|
||||||
import negativeEmbed from '../core/interaction/negativeEmbed.js';
|
import negativeEmbed from '../core/interaction/negativeEmbed.js';
|
||||||
|
import warningEmbed from '../core/interaction/warningEmbed.js';
|
||||||
import { DISCORD_TOKEN } from '../core/process/args.js';
|
import { DISCORD_TOKEN } from '../core/process/args.js';
|
||||||
import getClientId from '../core/process/getClientId.js';
|
import getClientId from '../core/process/getClientId.js';
|
||||||
import isDev from '../core/process/isDev.js';
|
import isDev from '../core/process/isDev.js';
|
||||||
|
import { psa } from '../core/process/psa.js';
|
||||||
import render from '../core/ui/render.js';
|
import render from '../core/ui/render.js';
|
||||||
import { handleError } from './error.js';
|
import { handleError } from './error.js';
|
||||||
|
|
||||||
@@ -149,10 +151,17 @@ export default async function interactionCreate(
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await command.execute(interaction);
|
const result = await command.execute(interaction);
|
||||||
|
const normalizedResult = Array.isArray(result) ? result : [result];
|
||||||
const reply: InteractionEditReplyOptions = {};
|
const reply: InteractionEditReplyOptions = {};
|
||||||
|
|
||||||
|
if (psa.data) {
|
||||||
|
normalizedResult.push(
|
||||||
|
warningEmbed(psa.data.title, psa.data.description),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
(Array.isArray(result) ? result : [result]).map(async (item) => {
|
normalizedResult.map(async (item) => {
|
||||||
if (item instanceof EmbedBuilder) {
|
if (item instanceof EmbedBuilder) {
|
||||||
if (!reply.embeds) reply.embeds = [];
|
if (!reply.embeds) reply.embeds = [];
|
||||||
reply.embeds.push(item);
|
reply.embeds.push(item);
|
||||||
|
|||||||
Reference in new issue
Block a user