mirror of
https://github.com/janderedev/automod.git
synced 2024-12-22 10:45:27 +00:00
dont you fucking love it when you leak your db secret in #general
This commit is contained in:
parent
d6ef3c8697
commit
2b851c813c
|
@ -1,6 +1,7 @@
|
||||||
import Command from "../../struct/Command";
|
import Command from "../../struct/Command";
|
||||||
import { Message } from "revolt.js/dist/maps/Messages";
|
import { Message } from "revolt.js/dist/maps/Messages";
|
||||||
import { inspect } from 'util';
|
import { inspect } from 'util';
|
||||||
|
import { client } from "../..";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'eval',
|
name: 'eval',
|
||||||
|
@ -23,19 +24,31 @@ export default {
|
||||||
await m?.edit({ content: `## **Promise**<pending>` });
|
await m?.edit({ content: `## **Promise**<pending>` });
|
||||||
e.then((res) => {
|
e.then((res) => {
|
||||||
m?.edit({
|
m?.edit({
|
||||||
content: `## **Promise**<resolved>\n\`\`\`js\n${`${inspect(res)}`.substr(0, 1960)}\n\`\`\``
|
content: `## **Promise**<resolved>\n\`\`\`js\n${render(res)}\n\`\`\``
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((res) => {
|
.catch((res) => {
|
||||||
m?.edit({
|
m?.edit({
|
||||||
content: `## **Promise**<rejected>\n\`\`\`js\n${`${inspect(res)}`.substr(0, 1960)}\n\`\`\``
|
content: `## **Promise**<rejected>\n\`\`\`js\n${render(res)}\n\`\`\``
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
message.channel?.sendMessage(`\`\`\`js\n${inspect(e).substr(0, 1980)}\n\`\`\``);
|
message.channel?.sendMessage(`\`\`\`js\n${render(e)}\n\`\`\``);
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
m?.edit({ content: `## Execution failed\n\`\`\`js\n${inspect(e).substr(0, 1960)}\n\`\`\`` });
|
m?.edit({ content: `## Execution failed\n\`\`\`js\n${render(e)}\n\`\`\`` });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} as Command;
|
} as Command;
|
||||||
|
|
||||||
|
function removeSecrets(input: string): string {
|
||||||
|
if (process.env['DB_PASS']) input = input.replace(new RegExp(process.env['DB_PASS']!, 'gi'), '[Secret redacted]');
|
||||||
|
if (process.env['DB_URL']) input = input.replace(new RegExp(process.env['DB_URL']!, 'gi'), '[Secret redacted]');
|
||||||
|
input = input.replace(new RegExp(process.env['BOT_TOKEN']!, 'gi'), '[Secret redacted]');
|
||||||
|
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
function render(input: any): string {
|
||||||
|
return removeSecrets(inspect(input)).substr(0, 1960);
|
||||||
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Message } from "revolt.js/dist/maps/Messages";
|
||||||
import { client } from "../..";
|
import { client } from "../..";
|
||||||
import Infraction from "../../struct/antispam/Infraction";
|
import Infraction from "../../struct/antispam/Infraction";
|
||||||
import InfractionType from "../../struct/antispam/InfractionType";
|
import InfractionType from "../../struct/antispam/InfractionType";
|
||||||
import { isModerator, parseUser } from "../util";
|
import { isModerator, NO_MANAGER_MSG, parseUser } from "../util";
|
||||||
import Day from 'dayjs';
|
import Day from 'dayjs';
|
||||||
import RelativeTime from 'dayjs/plugin/relativeTime';
|
import RelativeTime from 'dayjs/plugin/relativeTime';
|
||||||
import Xlsx from 'xlsx';
|
import Xlsx from 'xlsx';
|
||||||
|
@ -18,7 +18,7 @@ export default {
|
||||||
description: 'Show all user infractions',
|
description: 'Show all user infractions',
|
||||||
syntax: '/warns; /warns @username; /warns @username export-csv',
|
syntax: '/warns; /warns @username; /warns @username export-csv',
|
||||||
run: async (message: Message, args: string[]) => {
|
run: async (message: Message, args: string[]) => {
|
||||||
if (!await isModerator(message.member!)) return;
|
if (!await isModerator(message.member!)) return message.reply(NO_MANAGER_MSG);
|
||||||
|
|
||||||
let collection = client.db.get('infractions');
|
let collection = client.db.get('infractions');
|
||||||
let infractions: Array<Infraction> = await collection.find({
|
let infractions: Array<Infraction> = await collection.find({
|
||||||
|
|
Loading…
Reference in a new issue