From 1d3c52fc4f4de05b6f667d715f6157d49991cd9f Mon Sep 17 00:00:00 2001 From: "gitpod-io[bot]" Date: Mon, 16 May 2022 11:31:11 +0000 Subject: [PATCH] feat: add statcord --- package.json | 1 + src/augment.d.ts | 2 ++ src/bot.ts | 7 +++++ src/listeners/client/interactionCreate.ts | 14 ++++++++++ yarn.lock | 33 ++++++++++++++++++++++- 5 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 src/listeners/client/interactionCreate.ts diff --git a/package.json b/package.json index 693d2e42..78696e20 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "dependencies": { "@discordjs/builders": "^0.13.0", "@discordjs/opus": "^0.7.0", + "@kaname-png/plugin-statcord": "^1.3.4", "@prisma/client": "^3.14.0", "@sapphire/decorators": "^4.3.4", "@sapphire/framework": "^3.0.0-next.fd7be0b.0", diff --git a/src/augment.d.ts b/src/augment.d.ts index e4ca776d..6172106f 100644 --- a/src/augment.d.ts +++ b/src/augment.d.ts @@ -14,8 +14,10 @@ declare global { interface ProcessEnv { GUILD: string; OWNER: string; + CLIENT_ID: string; CONSOLE_URL: string; GUILDS_URL: string; + STATCORD_API_KEY: string; } } } diff --git a/src/bot.ts b/src/bot.ts index f0debdfc..9f7d4a20 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -4,6 +4,7 @@ import {Logger} from "./logger"; import {container, LogLevel, SapphireClient} from "@sapphire/framework"; import "@sapphire/plugin-logger/register"; import "@sapphire/plugin-i18next/register"; +import "@kaname-png/plugin-statcord/register"; import {PrismaClient} from "@prisma/client"; config(); @@ -20,6 +21,12 @@ const client = new SapphireClient({ "en-US" ); } + }, + statcord: { + client_id: process.env.CLIENT_ID, + key: process.env.STATCORD_API_KEY, + autopost: true, + debug: true } }); container.player = new Player(client); diff --git a/src/listeners/client/interactionCreate.ts b/src/listeners/client/interactionCreate.ts new file mode 100644 index 00000000..eebfa558 --- /dev/null +++ b/src/listeners/client/interactionCreate.ts @@ -0,0 +1,14 @@ +import {ApplyOptions} from "@sapphire/decorators"; +import {Events, Listener, ListenerOptions} from "@sapphire/framework"; +import type {Interaction, CacheType} from "discord.js"; + +@ApplyOptions({ + event: Events.InteractionCreate +}) +export class InteractionCreateListener extends Listener { + public run(interaction: Interaction): unknown { + if (!interaction.isCommand()) return; + + return this.container.statcord.postCommand(interaction.commandName, interaction.user.id); + } +} diff --git a/yarn.lock b/yarn.lock index 70826885..fe180d0e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -143,6 +143,17 @@ __metadata: languageName: node linkType: hard +"@kaname-png/plugin-statcord@npm:^1.3.4": + version: 1.3.4 + resolution: "@kaname-png/plugin-statcord@npm:1.3.4" + dependencies: + "@sapphire/fetch": ^2.3.1 + systeminformation: ^5.11.14 + tslib: ^2.4.0 + checksum: 2870011a4d0c55eea916b734536fe7bd4ab1a8eb196ac7f13e757280bf93cc8a9fd994ecb007a51edac6d65e8be516d0de17be2734d31d8a4c5c662d888a8188 + languageName: node + linkType: hard + "@nodelib/fs.scandir@npm:2.1.5": version: 2.1.5 resolution: "@nodelib/fs.scandir@npm:2.1.5" @@ -270,6 +281,15 @@ __metadata: languageName: node linkType: hard +"@sapphire/fetch@npm:^2.3.1": + version: 2.3.1 + resolution: "@sapphire/fetch@npm:2.3.1" + dependencies: + cross-fetch: ^3.1.5 + checksum: 3cb6d2a74fd107901d6902b8949ae7b3780da7efb519fc411fee1496d4d0d72cec1a68e19fc6ac47984f37f509567dbbc4ce82bea5c1ff437f119fc0afa8359d + languageName: node + linkType: hard + "@sapphire/framework@npm:^3.0.0-next.fd7be0b.0": version: 3.0.0-next.fd7be0b.0 resolution: "@sapphire/framework@npm:3.0.0-next.fd7be0b.0" @@ -1075,7 +1095,7 @@ __metadata: languageName: node linkType: hard -"cross-fetch@npm:~3.1.4": +"cross-fetch@npm:^3.1.5, cross-fetch@npm:~3.1.4": version: 3.1.5 resolution: "cross-fetch@npm:3.1.5" dependencies: @@ -3016,6 +3036,7 @@ __metadata: "@commitlint/config-angular": 17.0.0 "@discordjs/builders": ^0.13.0 "@discordjs/opus": ^0.7.0 + "@kaname-png/plugin-statcord": ^1.3.4 "@prisma/client": ^3.14.0 "@sapphire/decorators": ^4.3.4 "@sapphire/eslint-config": 4.3.5 @@ -3697,6 +3718,16 @@ __metadata: languageName: node linkType: hard +"systeminformation@npm:^5.11.14": + version: 5.11.15 + resolution: "systeminformation@npm:5.11.15" + bin: + systeminformation: lib/cli.js + checksum: 29bfd93cd6b733a2730a40daba415ecccb030b1dd965f872d0d0b272a935d31ab35c092ad273ce174f10f123899de03d95295336e5f9c68df0eb4a93b8eaed21 + conditions: (os=darwin | os=linux | os=win32 | os=freebsd | os=openbsd | os=netbsd | os=sunos | os=android) + languageName: node + linkType: hard + "tar@npm:^2.0.0": version: 2.2.2 resolution: "tar@npm:2.2.2"