aboutsummaryrefslogtreecommitdiff
path: root/src/commands/dev
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-01-08 20:08:16 -0500
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-01-08 20:08:16 -0500
commite0531157a745ac6178d55cc159b5932fa36ff20f (patch)
treea8de340d0c48269619e9bfde536932eb08556593 /src/commands/dev
parent0e160ae77477f0986a02746e84158329299f438f (diff)
downloadtanzanite-e0531157a745ac6178d55cc159b5932fa36ff20f.tar.gz
tanzanite-e0531157a745ac6178d55cc159b5932fa36ff20f.tar.bz2
tanzanite-e0531157a745ac6178d55cc159b5932fa36ff20f.zip
database migrations - use jsonb over text + JSON.parse, refactor bad word & automod - store word in shared db
closes: #53
Diffstat (limited to 'src/commands/dev')
-rw-r--r--src/commands/dev/eval.ts18
-rw-r--r--src/commands/dev/test.ts10
2 files changed, 24 insertions, 4 deletions
diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts
index 5b2f27a..4eb25dc 100644
--- a/src/commands/dev/eval.ts
+++ b/src/commands/dev/eval.ts
@@ -8,6 +8,7 @@ import {
Guild,
Level,
ModLog,
+ Shared,
StickyRole,
type ArgType
} from '#lib';
@@ -132,6 +133,15 @@ export default class EvalCommand extends BushCommand {
prompt: 'Would you like to inspect the prototype chain to find methods?',
slashType: 'BOOLEAN',
optional: true
+ },
+ {
+ id: 'async',
+ description: 'Whether or not to wrap the code in an async function.',
+ match: 'flag',
+ flag: '--async',
+ prompt: 'Would you like to wrap the code in an async function?',
+ slashType: 'BOOLEAN',
+ optional: true
}
],
slash: true,
@@ -144,8 +154,8 @@ export default class EvalCommand extends BushCommand {
public override async exec(
message: BushMessage | BushSlashMessage,
args: {
- sel_depth: ArgType<'integer'>;
code: ArgType<'string'>;
+ sel_depth: ArgType<'integer'>;
sudo: ArgType<'boolean'>;
silent: ArgType<'boolean'>;
deleteMSG: ArgType<'boolean'>;
@@ -153,6 +163,7 @@ export default class EvalCommand extends BushCommand {
hidden: ArgType<'boolean'>;
show_proto: ArgType<'boolean'>;
show_methods: ArgType<'boolean'>;
+ async: ArgType<'boolean'>;
}
) {
if (!message.author.isOwner())
@@ -161,7 +172,8 @@ export default class EvalCommand extends BushCommand {
await message.interaction.deferReply({ ephemeral: args.silent });
}
const isTypescript = args.typescript || args.code.includes('```ts');
- const rawCode = args.code.replace(/[“”]/g, '"').replace(/```*(?:js|ts)?/g, '');
+ let rawCode = args.code.replace(/[“”]/g, '"').replace(/```*(?:js|ts)?/g, '');
+ if (args.async) rawCode = `(async () => {${rawCode}})()`;
const code: { ts: string | null; js: string; lang: 'ts' | 'js' } = {
ts: isTypescript ? rawCode : null,
@@ -237,4 +249,4 @@ export default class EvalCommand extends BushCommand {
}
}
-/** @typedef {ActivePunishment|Global|Guild|Level|ModLog|StickyRole|ButtonInteraction|Collection|Collector|CommandInteraction|ContextMenuInteraction|DMChannel|Emoji|Interaction|InteractionCollector|Message|MessageActionRow|MessageAttachment|MessageButton|MessageCollector|MessageSelectMenu|ReactionCollector|Util|Canvas} VSCodePleaseDontRemove */
+/** @typedef {ActivePunishment|Global|Guild|Level|ModLog|StickyRole|ButtonInteraction|Collection|Collector|CommandInteraction|ContextMenuInteraction|DMChannel|Emoji|Interaction|InteractionCollector|Message|MessageActionRow|MessageAttachment|MessageButton|MessageCollector|MessageSelectMenu|ReactionCollector|Util|Canvas|Shared} VSCodePleaseDontRemove */
diff --git a/src/commands/dev/test.ts b/src/commands/dev/test.ts
index 2c4e34d..50532f8 100644
--- a/src/commands/dev/test.ts
+++ b/src/commands/dev/test.ts
@@ -1,6 +1,8 @@
-import { BushCommand, ButtonPaginator, type BushMessage } from '#lib';
+import { BushCommand, ButtonPaginator, Shared, type BushMessage } from '#lib';
import { MessageActionRow, MessageButton, MessageEmbed, type ApplicationCommand, type Collection } from 'discord.js';
import { MessageButtonStyles } from 'discord.js/typings/enums';
+import badLinksSecretArray from '../../lib/badlinks-secret.js';
+import badLinksArray from '../../lib/badlinks.js';
export default class TestCommand extends BushCommand {
public constructor() {
@@ -148,6 +150,12 @@ export default class TestCommand extends BushCommand {
return await message.util.reply(`${util.emojis.success} Removed guild commands and global commands.`);
} else if (['drop down', 'drop downs', 'select menu', 'select menus'].includes(args?.feature?.toLowerCase())) {
+ } else if (['sync links'].includes(args?.feature?.toLowerCase())) {
+ const row = (await Shared.findByPk(0))!;
+ row.badLinks = badLinksArray;
+ row.badLinksSecret = badLinksSecretArray;
+ await row.save();
+ return await message.util.reply(`${util.emojis.success} Updated bad links.`);
}
return await message.util.reply(responses[Math.floor(Math.random() * responses.length)]);
}