remove logger

This commit is contained in:
Skillz
2020-09-22 19:08:14 -04:00
parent 2eab6d6789
commit 18d483144c
7 changed files with 10 additions and 64 deletions
+7 -7
View File
@@ -20,14 +20,14 @@ import { cache } from "https://x.nest.land/Discordeno@8.4.1/src/utils/cache.ts";
import logger from "https://x.nest.land/Discordeno@8.4.1/src/utils/logger.ts"; import logger from "https://x.nest.land/Discordeno@8.4.1/src/utils/logger.ts";
botCache.eventHandlers.ready = function () { botCache.eventHandlers.ready = function () {
logger.info(`Loaded ${botCache.arguments.size} Argument(s)`); console.log(`Loaded ${botCache.arguments.size} Argument(s)`);
logger.info(`Loaded ${botCache.commands.size} Command(s)`); console.log(`Loaded ${botCache.commands.size} Command(s)`);
logger.info(`Loaded ${Object.keys(botCache.eventHandlers).length} Event(s)`); console.log(`Loaded ${Object.keys(botCache.eventHandlers).length} Event(s)`);
logger.info(`Loaded ${botCache.inhibitors.size} Inhibitor(s)`); console.log(`Loaded ${botCache.inhibitors.size} Inhibitor(s)`);
logger.info(`Loaded ${botCache.monitors.size} Monitor(s)`); console.log(`Loaded ${botCache.monitors.size} Monitor(s)`);
logger.info(`Loaded ${botCache.tasks.size} Task(s)`); console.log(`Loaded ${botCache.tasks.size} Task(s)`);
logger.success( console.log(
`[READY] Bot is online and ready in ${cache.guilds.size} guild(s)!`, `[READY] Bot is online and ready in ${cache.guilds.size} guild(s)!`,
); );
}; };
-1
View File
@@ -45,7 +45,6 @@ export * from "./src/types/role.ts";
export * from "./src/utils/cache.ts"; export * from "./src/utils/cache.ts";
export * from "./src/utils/cdn.ts"; export * from "./src/utils/cdn.ts";
export * from "./src/utils/collection.ts"; export * from "./src/utils/collection.ts";
export * from "./src/utils/logger.ts";
export * from "./src/utils/permissions.ts"; export * from "./src/utils/permissions.ts";
export * from "./src/utils/utils.ts"; export * from "./src/utils/utils.ts";
+1
View File
@@ -99,6 +99,7 @@ export async function createGuildChannel(
name, name,
permission_overwrites: options?.permission_overwrites?.map((perm) => ({ permission_overwrites: options?.permission_overwrites?.map((perm) => ({
...perm, ...perm,
allow: perm.allow.reduce( allow: perm.allow.reduce(
(bits, p) => bits |= BigInt(Permissions[p]), (bits, p) => bits |= BigInt(Permissions[p]),
BigInt(0), BigInt(0),
+1 -3
View File
@@ -12,14 +12,12 @@ import type { FetchMembersOptions } from "../types/guild.ts";
import type { BotStatusRequest } from "../utils/utils.ts"; import type { BotStatusRequest } from "../utils/utils.ts";
import { handleDiscordPayload } from "./shardingManager.ts"; import { handleDiscordPayload } from "./shardingManager.ts";
import { logRed } from "../utils/logger.ts";
import { GatewayOpcode } from "../types/discord.ts"; import { GatewayOpcode } from "../types/discord.ts";
import { import {
eventHandlers, eventHandlers,
botGatewayData, botGatewayData,
} from "./client.ts"; } from "./client.ts";
import { delay } from "https://deno.land/std@0.67.0/async/delay.ts"; import { delay } from "https://deno.land/std@0.67.0/async/delay.ts";
import { cache } from "../utils/cache.ts";
import { inflate } from "https://deno.land/x/zlib.es@v1.0.0/mod.ts"; import { inflate } from "https://deno.land/x/zlib.es@v1.0.0/mod.ts";
const basicShards = new Map<number, BasicShard>(); const basicShards = new Map<number, BasicShard>();
@@ -78,7 +76,7 @@ export async function createBasicShard(
// These error codes should just crash the projects // These error codes should just crash the projects
if ([4004, 4005, 4012, 4013, 4014].includes(message.code)) { if ([4004, 4005, 4012, 4013, 4014].includes(message.code)) {
logRed(`Close :( ${JSON.stringify(message)}`); console.error(`Close :( ${JSON.stringify(message)}`);
eventHandlers.debug?.( eventHandlers.debug?.(
{ {
type: "websocketErrored", type: "websocketErrored",
-2
View File
@@ -4,7 +4,6 @@ import { baseEndpoints } from "../constants/discord.ts";
import type { RequestMethods } from "../types/fetch.ts"; import type { RequestMethods } from "../types/fetch.ts";
import { Errors } from "../types/errors.ts"; import { Errors } from "../types/errors.ts";
import { logRed } from "../utils/logger.ts";
import { delay } from "https://deno.land/std@0.67.0/async/delay.ts"; import { delay } from "https://deno.land/std@0.67.0/async/delay.ts";
const pathQueues: { [key: string]: QueuedRequest[] } = {}; const pathQueues: { [key: string]: QueuedRequest[] } = {};
@@ -290,7 +289,6 @@ function handleStatusCode(response: Response) {
} }
console.error(response); console.error(response);
logRed(response);
switch (status) { switch (status) {
case HttpResponseCode.BadRequest: case HttpResponseCode.BadRequest:
+1 -2
View File
@@ -8,7 +8,6 @@ import type { FetchMembersOptions } from "../types/guild.ts";
import type { DebugArg } from "../types/options.ts"; import type { DebugArg } from "../types/options.ts";
import { GatewayOpcode } from "../types/discord.ts"; import { GatewayOpcode } from "../types/discord.ts";
import { logRed } from "../utils/logger.ts";
import { delay } from "https://deno.land/std@0.67.0/async/delay.ts"; import { delay } from "https://deno.land/std@0.67.0/async/delay.ts";
import { import {
connectWebSocket, connectWebSocket,
@@ -172,7 +171,7 @@ const createShard = async (
// These error codes should just crash the projects // These error codes should just crash the projects
if ([4004, 4005, 4012, 4013, 4014].includes(message.code)) { if ([4004, 4005, 4012, 4013, 4014].includes(message.code)) {
logRed(`Close :( ${JSON.stringify(message)}`); console.error(`Close :( ${JSON.stringify(message)}`);
postDebug({ type: "websocketErrored", data: { shardID, message } }); postDebug({ type: "websocketErrored", data: { shardID, message } });
throw new Error( throw new Error(
-49
View File
@@ -1,49 +0,0 @@
import {
blue,
green,
red,
yellow,
} from "https://deno.land/std@0.67.0/fmt/colors.ts";
export const getTime = () => {
const now = new Date();
const hours = now.getHours();
const minute = now.getMinutes();
let hour = hours;
let amOrPm = `AM`;
if (hour > 12) {
amOrPm = `PM`;
hour = hour - 12;
}
return `${hour >= 10 ? hour : `0${hour}`}:${
minute >= 10 ? minute : `0${minute}`
} ${amOrPm}`;
};
export const logGreen = (text: unknown) => {
console.log(green(`[${getTime()}] => ${JSON.stringify(text)}`));
};
export const logBlue = (text: unknown) => {
console.log(blue(`[${getTime()}] => ${JSON.stringify(text)}`));
};
export const logRed = (text: unknown) => {
console.log(red(`[${getTime()}] => ${JSON.stringify(text)}`));
};
export const logYellow = (text: unknown) => {
console.log(yellow(`[${getTime()}] => ${JSON.stringify(text)}`));
};
export const logger = {
getTime,
success: logGreen,
info: logBlue,
error: logRed,
warn: logYellow,
};
export default logger;