better logging

main
Benjamin Kraft 4 months ago
parent 11b6939335
commit 2eebf996c5
  1. 1
      src/bot.ts
  2. 2
      src/commands/add.ts
  3. 2
      src/commands/list.ts
  4. 2
      src/commands/ping.ts
  5. 2
      src/commands/remove.ts
  6. 4
      src/commands/update.ts
  7. 1
      src/index.ts
  8. 4
      src/player.ts
  9. 17
      src/util.ts

@ -2,6 +2,7 @@ import {Client, Collection, Events, GatewayIntentBits, Interaction} from "discor
import {Player} from "./player";
import fs from "node:fs";
import {Command, loadCommands} from "./command";
require("./util.js");
export class UEMEloBot extends Client {

@ -15,6 +15,8 @@ class Add extends Command {
if (!interaction.isChatInputCommand())
return;
console.log("Add command used");
let client = interaction.client as UEMEloBot;
const riotId = interaction.options.getString("riot-id", true);

@ -12,6 +12,8 @@ class List extends Command {
if (!interaction.isChatInputCommand())
return;
console.log("List command used");
const serverID = await checkServer(interaction);
if (!serverID)
return;

@ -9,6 +9,8 @@ class Ping extends Command {
if (!interaction.isChatInputCommand())
return;
console.log("Ping command used");
await interaction.reply({content: "Pong", ephemeral: true});
}
}

@ -15,6 +15,8 @@ class Remove extends Command {
if (!interaction.isChatInputCommand())
return;
console.log("Remove command used");
let client = interaction.client as UEMEloBot;
const riotId = interaction.options.getString("riot-id", true);

@ -4,12 +4,14 @@ import {UEMEloBot} from "../bot";
class Update extends Command {
constructor() {
super("update", "Ränge jetzt aktualisieren (passiert automatisch alle 30min)");
super("update", "Ränge jetzt aktualisieren (passiert automatisch alle 20min)");
}
async execute(interaction: Interaction) {
if (!interaction.isChatInputCommand())
return;
console.log("Update command used");
await interaction.deferReply({ephemeral: true});
let client = interaction.client as UEMEloBot;

@ -1,6 +1,7 @@
require("dotenv").config();
import {UEMEloBot} from "./bot";
import readline from "readline";
require("util");
readline.createInterface({input: process.stdin}).on('line', async line => {
if (line == "stop")

@ -69,12 +69,8 @@ export class Player {
try {
entries = await tryRegion(PlatformId.EUW1);
} catch (error){
let response = error as Response;
console.error(await response.json());
console.log(`Trying EUNE Region...`);
try {
entries = await tryRegion(PlatformId.EUNE1);
console.log(`Success with EUNE`);
} catch (error){
let response = error as Response;
console.error(await response.json());

@ -7,4 +7,19 @@ export async function checkServer(interaction: ChatInputCommandInteraction){
await interaction.reply({content: "Fehler!", ephemeral: true});
}
return serverID;
}
}
const originalLog = console.log;
const originalError = console.error;
function getTimestamp() {
return new Date().toISOString();
}
console.log = function(...args) {
originalLog(`[${getTimestamp()}]`, ...args);
};
console.error = function(...args) {
originalError(`[${getTimestamp()}]`, ...args);
};
Loading…
Cancel
Save