mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-03 22:15:37 +00:00
fix: more type annotation
This commit is contained in:
1 parent
3ac692d8eb
commit
2560f0fe9a
65 files changed
+408
-343
No files matched your search
@@ -2,10 +2,10 @@ import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const cookies = require(path.resolve('./cookies.json'));
|
||||
const cookies: { name: string; value: string }[] = require(path.resolve('./cookies.json'));
|
||||
|
||||
try {
|
||||
const cookieString = cookies
|
||||
const cookieString: string = cookies
|
||||
.map(({ name, value }: { name: string; value: string }) => {
|
||||
return `${name}=${value}`;
|
||||
})
|
||||
|
||||
@@ -3,9 +3,11 @@ import https from 'node:https';
|
||||
|
||||
import loggerModule from '../../services/logger';
|
||||
import { PostBotStatsParams, PostBotStatsSite } from '../../types/utilTypes';
|
||||
import { Logger } from 'pino';
|
||||
import { ClientRequest, ClientRequestArgs } from 'node:http';
|
||||
|
||||
export const postBotStats = async ({ client, executionId }: PostBotStatsParams) => {
|
||||
const logger = loggerModule.child({
|
||||
const logger: Logger = loggerModule.child({
|
||||
source: 'postBotStats.js',
|
||||
module: 'utilOther',
|
||||
name: 'postBotStats',
|
||||
@@ -18,16 +20,16 @@ export const postBotStats = async ({ client, executionId }: PostBotStatsParams)
|
||||
return;
|
||||
}
|
||||
|
||||
let guildCount = 0;
|
||||
let memberCount = 0;
|
||||
const shardCount = client.shard.count;
|
||||
const shardId = client.shard.ids[0];
|
||||
let guildCount: number = 0;
|
||||
let memberCount: number = 0;
|
||||
const shardCount: number = client.shard.count;
|
||||
const shardId: number = client.shard.ids[0];
|
||||
|
||||
logger.debug('Gathering data about guild and member count from shards...');
|
||||
await client.shard
|
||||
.fetchClientValues('guilds.cache')
|
||||
.then((results) => {
|
||||
const guildCaches = results as Collection<string, Guild>[];
|
||||
const guildCaches: Collection<string, Guild>[] = results as Collection<string, Guild>[];
|
||||
guildCaches.map((guildCache) => {
|
||||
if (guildCache) {
|
||||
guildCount += guildCache.size;
|
||||
@@ -132,7 +134,7 @@ export const postBotStats = async ({ client, executionId }: PostBotStatsParams)
|
||||
return;
|
||||
}
|
||||
|
||||
const options = {
|
||||
const options: ClientRequestArgs = {
|
||||
protocol: 'https:',
|
||||
hostname: site.hostname,
|
||||
port: 443,
|
||||
@@ -144,7 +146,7 @@ export const postBotStats = async ({ client, executionId }: PostBotStatsParams)
|
||||
}
|
||||
};
|
||||
|
||||
const request = https.request(options, (res) => {
|
||||
const request: ClientRequest = https.request(options, (res) => {
|
||||
if (typeof res.statusCode === 'number') {
|
||||
res.statusCode === 200
|
||||
? logger.debug(`Request to ${site.hostname}: statusCode: ${res.statusCode}`)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import config from 'config';
|
||||
import { Client } from 'discord.js';
|
||||
import { Channel, Client } from 'discord.js';
|
||||
|
||||
import { Logger } from 'pino';
|
||||
import loggerModule from '../../services/logger';
|
||||
import { LoadTestOptions } from '../../types/configTypes';
|
||||
import { StartLoadTestParams } from '../../types/utilTypes';
|
||||
@@ -8,7 +9,7 @@ import { StartLoadTestParams } from '../../types/utilTypes';
|
||||
const loadTestOptions: LoadTestOptions = config.get('loadTestOptions');
|
||||
|
||||
export const startLoadTest = async ({ client, executionId }: StartLoadTestParams) => {
|
||||
const logger = loggerModule.child({
|
||||
const logger: Logger = loggerModule.child({
|
||||
source: 'startLoadTest.js',
|
||||
module: 'utilOther',
|
||||
name: 'startLoadTest',
|
||||
@@ -21,15 +22,15 @@ export const startLoadTest = async ({ client, executionId }: StartLoadTestParams
|
||||
return;
|
||||
}
|
||||
|
||||
const channelIds = loadTestOptions.channelIdsToJoin;
|
||||
const track = loadTestOptions.trackUrl;
|
||||
const channelIds: string[] = loadTestOptions.channelIdsToJoin;
|
||||
const track: string = loadTestOptions.trackUrl;
|
||||
|
||||
logger.info(`Starting load test in ${channelIds.length} specified channels.`);
|
||||
|
||||
channelIds.forEach((each) => {
|
||||
client.shard?.broadcastEval(
|
||||
async (shardClient: Client, { channelId, track }: { channelId: string; track: string }) => {
|
||||
const channel = shardClient.channels.cache.get(channelId);
|
||||
const channel: Channel | undefined = shardClient.channels.cache.get(channelId);
|
||||
if (channel) {
|
||||
/* eslint-disable no-undef */
|
||||
// @ts-ignore
|
||||
|
||||
Reference in new issue
Block a user