deno fmt + rework api subcommands to be a switch statement

This commit is contained in:
Ean Milligan (Bastion) 2022-05-28 00:09:09 -04:00
parent 7cf62d44aa
commit 6cfe98e954
5 changed files with 43 additions and 30 deletions

View File

@ -3,8 +3,8 @@ import {
// Discordeno deps // Discordeno deps
DiscordenoMessage, DiscordenoMessage,
hasGuildPermissions, hasGuildPermissions,
log,
// Log4Deno deps // Log4Deno deps
log,
LT, LT,
} from '../../deps.ts'; } from '../../deps.ts';
import apiCommands from './apiCmd/_index.ts'; import apiCommands from './apiCmd/_index.ts';
@ -34,26 +34,39 @@ export const api = async (message: DiscordenoMessage, args: string[]) => {
// Makes sure the user is authenticated to run the API command // Makes sure the user is authenticated to run the API command
if (await hasGuildPermissions(message.authorId, message.guildId, ['ADMINISTRATOR'])) { if (await hasGuildPermissions(message.authorId, message.guildId, ['ADMINISTRATOR'])) {
switch (apiArg) {
case 'help':
case 'h':
// [[api help // [[api help
// Shows API help details // Shows API help details
if (apiArg === 'help' || apiArg === 'h') {
apiCommands.help(message); apiCommands.help(message);
} // [[api allow/block break;
case 'allow':
case 'block':
case 'enable':
case 'disable':
// [[api allow/block
// Lets a guild admin allow or ban API rolls from happening in said guild // Lets a guild admin allow or ban API rolls from happening in said guild
else if (apiArg === 'allow' || apiArg === 'block' || apiArg === 'enable' || apiArg === 'disable') {
apiCommands.allowBlock(message, apiArg); apiCommands.allowBlock(message, apiArg);
} // [[api delete break;
case 'delete':
// [[api delete
// Lets a guild admin delete their server from the database // Lets a guild admin delete their server from the database
else if (apiArg === 'delete') {
apiCommands.deleteGuild(message); apiCommands.deleteGuild(message);
} // [[api status break;
case 'status':
// [[api status
// Lets a guild admin check the status of API rolling in said guild // Lets a guild admin check the status of API rolling in said guild
else if (apiArg === 'status') {
apiCommands.status(message); apiCommands.status(message);
} // [[api show-warn/hide-warn break;
case 'show-warn':
case 'hide-warn':
// [[api show-warn/hide-warn
// Lets a guild admin decide if the API warning should be shown on messages from the API // Lets a guild admin decide if the API warning should be shown on messages from the API
else if (apiArg === 'show-warn' || apiArg === 'hide-warn') {
apiCommands.showHideWarn(message, apiArg); apiCommands.showHideWarn(message, apiArg);
break;
default:
break;
} }
} else { } else {
message.send({ message.send({

View File

@ -8,7 +8,7 @@ import {
LT, LT,
sendMessage, sendMessage,
} from '../../deps.ts'; } from '../../deps.ts';
import { successColor, failColor, generateReport } from '../commandUtils.ts'; import { failColor, generateReport, successColor } from '../commandUtils.ts';
export const report = (message: DiscordenoMessage, args: string[]) => { export const report = (message: DiscordenoMessage, args: string[]) => {
// Light telemetry to see how many times a command is being run // Light telemetry to see how many times a command is being run

View File

@ -11,7 +11,7 @@ import {
} from '../../deps.ts'; } from '../../deps.ts';
import solver from '../solver/_index.ts'; import solver from '../solver/_index.ts';
import { SolvedRoll } from '../solver/solver.d.ts'; import { SolvedRoll } from '../solver/solver.d.ts';
import { warnColor, infoColor1, generateCountDetailsEmbed, generateDMFailed, generateRollEmbed } from '../commandUtils.ts'; import { generateCountDetailsEmbed, generateDMFailed, generateRollEmbed, infoColor1, warnColor } from '../commandUtils.ts';
import rollFuncs from './roll/_index.ts'; import rollFuncs from './roll/_index.ts';
export const roll = async (message: DiscordenoMessage, args: string[], command: string) => { export const roll = async (message: DiscordenoMessage, args: string[], command: string) => {

View File

@ -8,7 +8,7 @@ import {
// Log4Deno deps // Log4Deno deps
LT, LT,
} from '../../deps.ts'; } from '../../deps.ts';
import { warnColor, generateStats } from '../commandUtils.ts'; import { generateStats, warnColor } from '../commandUtils.ts';
export const stats = async (message: DiscordenoMessage) => { export const stats = async (message: DiscordenoMessage) => {
// Light telemetry to see how many times a command is being run // Light telemetry to see how many times a command is being run