mirror of
https://github.com/kirameki-cafe/Yumi.git
synced 2026-09-13 10:49:20 +00:00
Added more debug logs
This commit is contained in:
+5
-1
@@ -7,6 +7,8 @@ import Logger from '../libs/Logger';
|
||||
import Cache from '../providers/Cache';
|
||||
import Prisma from '../providers/Prisma';
|
||||
|
||||
const LOGGING_TAG = '[DiscordCore]';
|
||||
|
||||
export default class Core extends DiscordModule {
|
||||
public id: string = 'Discord_Core';
|
||||
|
||||
@@ -28,13 +30,15 @@ export default class Core extends DiscordModule {
|
||||
|
||||
this.setActivity();
|
||||
setInterval(() => {
|
||||
Logger.verbose(LOGGING_TAG, 'Updating activity');
|
||||
this.setActivity();
|
||||
}, 5 * 60 * 1000);
|
||||
|
||||
Logger.info('Core started successfully');
|
||||
Logger.info(LOGGING_TAG, 'Core started successfully');
|
||||
}
|
||||
|
||||
async GuildCreate(guild: Guild) {
|
||||
Logger.info(LOGGING_TAG, `Joined guild ${guild.name} (${guild.id})`);
|
||||
if (await Prisma.client.guild.findFirst({ where: { id: guild.id } })) return;
|
||||
|
||||
await Prisma.client.guild.create({
|
||||
|
||||
@@ -16,6 +16,9 @@ import {
|
||||
unregisterAllGuildsCommands,
|
||||
unregisterAllGlobalCommands
|
||||
} from '../utils/DiscordInteraction';
|
||||
import Logger from '../libs/Logger';
|
||||
|
||||
const LOGGING_TAG = '[InteractionManager]';
|
||||
|
||||
const EMBEDS = {
|
||||
INTERACTION_INFO: (data: HybridInteractionMessage) => {
|
||||
@@ -97,6 +100,7 @@ export default class InteractionManager extends DiscordModule {
|
||||
|
||||
const funct = {
|
||||
unloadAll: async (data: HybridInteractionMessage) => {
|
||||
Logger.info(LOGGING_TAG, 'Unloading all interaction');
|
||||
let placeholder: HybridInteractionMessage | undefined;
|
||||
|
||||
let _placeholder = await sendHybridInteractionMessageResponse(data, {
|
||||
@@ -127,6 +131,7 @@ export default class InteractionManager extends DiscordModule {
|
||||
}
|
||||
},
|
||||
unloadGlobal: async (data: HybridInteractionMessage) => {
|
||||
Logger.info(LOGGING_TAG, 'Unloading all global interaction');
|
||||
let placeholder: HybridInteractionMessage | undefined;
|
||||
|
||||
let _placeholder = await sendHybridInteractionMessageResponse(data, {
|
||||
@@ -157,6 +162,7 @@ export default class InteractionManager extends DiscordModule {
|
||||
}
|
||||
},
|
||||
reloadGlobal: async (data: HybridInteractionMessage) => {
|
||||
Logger.info(LOGGING_TAG, 'Reloading all global interaction');
|
||||
let placeholder: HybridInteractionMessage | undefined;
|
||||
|
||||
let _placeholder = await sendHybridInteractionMessageResponse(data, {
|
||||
@@ -188,6 +194,7 @@ export default class InteractionManager extends DiscordModule {
|
||||
}
|
||||
},
|
||||
reloadAll: async (data: HybridInteractionMessage) => {
|
||||
Logger.info(LOGGING_TAG, 'Reloading all interaction');
|
||||
let placeholder: HybridInteractionMessage | undefined;
|
||||
|
||||
let _placeholder = await sendHybridInteractionMessageResponse(data, {
|
||||
|
||||
@@ -11,6 +11,9 @@ import Locale from '../services/Locale';
|
||||
|
||||
import DiscordModule, { HybridInteractionMessage } from '../utils/DiscordModule';
|
||||
import { makeSuccessEmbed, makeProcessingEmbed, sendHybridInteractionMessageResponse } from '../utils/DiscordMessage';
|
||||
import Logger from '../libs/Logger';
|
||||
|
||||
const LOGGING_TAG = '[Ping]';
|
||||
|
||||
enum MeasureType {
|
||||
Ping = 'ping',
|
||||
@@ -75,26 +78,36 @@ export default class Ping extends DiscordModule {
|
||||
let stringCurrent = `${entry.title}`;
|
||||
|
||||
if (entry.type === MeasureType.Ping) {
|
||||
Logger.debug(LOGGING_TAG, `Pinging ${entry.host}`);
|
||||
const res = await NodePing.promise.probe(entry.host!, { min_reply: 4 });
|
||||
|
||||
if (!res.alive) {
|
||||
Logger.debug(LOGGING_TAG, `Ping failed for ${entry.host} (not alive)`);
|
||||
stringCurrent += 'Failed';
|
||||
return finalString.push(stringCurrent);
|
||||
}
|
||||
|
||||
if (res.avg === 'unknown' || res.min === 'unknown' || res.max === 'unknown') {
|
||||
Logger.debug(LOGGING_TAG, `Ping failed for ${entry.host} (unknown)`);
|
||||
stringCurrent += 'Failed';
|
||||
return finalString.push(stringCurrent);
|
||||
}
|
||||
|
||||
Logger.debug(
|
||||
LOGGING_TAG,
|
||||
`Ping result for ${entry.host}: Avg: ${res.avg}ms, Min: ${res.min}ms, Max: ${res.max}ms`
|
||||
);
|
||||
|
||||
stringCurrent += `${parseFloat(res.avg).toFixed(1)}ms (${parseFloat(res.min).toFixed(
|
||||
1
|
||||
)}ms - ${parseFloat(res.max).toFixed(1)}ms)`;
|
||||
finalString.push(stringCurrent);
|
||||
} else if (entry.type === MeasureType.DiscordWebsocket) {
|
||||
Logger.debug(LOGGING_TAG, `Pinging DiscordWebsocket`);
|
||||
stringCurrent += `${Math.round(DiscordProvider.client.ws.ping).toFixed(1)}ms`;
|
||||
finalString.push(stringCurrent);
|
||||
} else if (entry.type === MeasureType.DiscordHTTPPing) {
|
||||
Logger.debug(LOGGING_TAG, `Pinging DiscordHTTPPing`);
|
||||
stringCurrent += `${Math.abs(afterEditDate - beforeEditDate).toFixed(1)}ms`;
|
||||
finalString.push(stringCurrent);
|
||||
}
|
||||
@@ -105,6 +118,8 @@ export default class Ping extends DiscordModule {
|
||||
{ concurrency: 5 }
|
||||
);
|
||||
|
||||
Logger.debug(LOGGING_TAG, `All pings done, sending message`);
|
||||
|
||||
finalString.push('');
|
||||
finalString.push(
|
||||
`💻 ${locale.__('ping.running_on', { HOST: os.hostname() })} ` +
|
||||
|
||||
@@ -7,6 +7,9 @@ import DiscordModule, { HybridInteractionMessage } from '../../utils/DiscordModu
|
||||
import { makeInfoEmbed, makeErrorEmbed, sendHybridInteractionMessageResponse } from '../../utils/DiscordMessage';
|
||||
import Environment from '../../providers/Environment';
|
||||
import ImagePorxy from '../../libs/ImageProxy';
|
||||
import Logger from '../../libs/Logger';
|
||||
|
||||
const LOGGING_TAG = '[VRChatUser]';
|
||||
|
||||
const EMBEDS = {
|
||||
NO_USER_FOUND: (data: HybridInteractionMessage) => {
|
||||
@@ -84,6 +87,8 @@ export default class VRChatUser {
|
||||
await data.getSlashCommand().deferReply();
|
||||
}
|
||||
|
||||
Logger.verbose(LOGGING_TAG, `Showing user ${user.displayName} (${user.id})`, JSON.stringify(user));
|
||||
|
||||
const embed = makeInfoEmbed({
|
||||
icon: null,
|
||||
title: `**${user.displayName}**`,
|
||||
|
||||
@@ -90,12 +90,4 @@ export default class VRChat extends DiscordModule {
|
||||
return await VRChatWorld.run(data, args);
|
||||
}
|
||||
}
|
||||
|
||||
private numberWithCommas(x: Number) {
|
||||
try {
|
||||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
} catch (err) {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user