deno fmt + rework api subcommands to be a switch statement
This commit is contained in:
parent
7cf62d44aa
commit
6cfe98e954
|
@ -208,7 +208,7 @@ export const generateRollEmbed = async (authorId: bigint, returnDetails: SolvedR
|
|||
},
|
||||
hasAttachment: false,
|
||||
attachment: {
|
||||
'blob': await new Blob(['' as BlobPart], { 'type': 'text'}),
|
||||
'blob': await new Blob(['' as BlobPart], { 'type': 'text' }),
|
||||
'name': 'rollDetails.txt',
|
||||
},
|
||||
};
|
||||
|
@ -224,7 +224,7 @@ Results have been messaged to the following GMs: ${modifiers.gms.join(' ')}`,
|
|||
},
|
||||
hasAttachment: false,
|
||||
attachment: {
|
||||
'blob': await new Blob(['' as BlobPart], { 'type': 'text'}),
|
||||
'blob': await new Blob(['' as BlobPart], { 'type': 'text' }),
|
||||
'name': 'rollDetails.txt',
|
||||
},
|
||||
};
|
||||
|
@ -257,7 +257,7 @@ ${details}`,
|
|||
},
|
||||
hasAttachment: false,
|
||||
attachment: {
|
||||
'blob': await new Blob(['' as BlobPart], { 'type': 'text'}),
|
||||
'blob': await new Blob(['' as BlobPart], { 'type': 'text' }),
|
||||
'name': 'rollDetails.txt',
|
||||
},
|
||||
};
|
||||
|
@ -277,7 +277,7 @@ ${details}`,
|
|||
},
|
||||
hasAttachment: false,
|
||||
attachment: {
|
||||
'blob': await new Blob(['' as BlobPart], { 'type': 'text'}),
|
||||
'blob': await new Blob(['' as BlobPart], { 'type': 'text' }),
|
||||
'name': 'rollDetails.txt',
|
||||
},
|
||||
};
|
||||
|
|
|
@ -3,8 +3,8 @@ import {
|
|||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
hasGuildPermissions,
|
||||
log,
|
||||
// Log4Deno deps
|
||||
log,
|
||||
LT,
|
||||
} from '../../deps.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
|
||||
if (await hasGuildPermissions(message.authorId, message.guildId, ['ADMINISTRATOR'])) {
|
||||
// [[api help
|
||||
// Shows API help details
|
||||
if (apiArg === 'help' || apiArg === 'h') {
|
||||
apiCommands.help(message);
|
||||
} // [[api allow/block
|
||||
// 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);
|
||||
} // [[api delete
|
||||
// Lets a guild admin delete their server from the database
|
||||
else if (apiArg === 'delete') {
|
||||
apiCommands.deleteGuild(message);
|
||||
} // [[api status
|
||||
// Lets a guild admin check the status of API rolling in said guild
|
||||
else if (apiArg === 'status') {
|
||||
apiCommands.status(message);
|
||||
} // [[api show-warn/hide-warn
|
||||
// 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);
|
||||
switch (apiArg) {
|
||||
case 'help':
|
||||
case 'h':
|
||||
// [[api help
|
||||
// Shows API help details
|
||||
apiCommands.help(message);
|
||||
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
|
||||
apiCommands.allowBlock(message, apiArg);
|
||||
break;
|
||||
case 'delete':
|
||||
// [[api delete
|
||||
// Lets a guild admin delete their server from the database
|
||||
apiCommands.deleteGuild(message);
|
||||
break;
|
||||
case 'status':
|
||||
// [[api status
|
||||
// Lets a guild admin check the status of API rolling in said guild
|
||||
apiCommands.status(message);
|
||||
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
|
||||
apiCommands.showHideWarn(message, apiArg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
message.send({
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
LT,
|
||||
sendMessage,
|
||||
} from '../../deps.ts';
|
||||
import { successColor, failColor, generateReport } from '../commandUtils.ts';
|
||||
import { failColor, generateReport, successColor } from '../commandUtils.ts';
|
||||
|
||||
export const report = (message: DiscordenoMessage, args: string[]) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
} from '../../deps.ts';
|
||||
import solver from '../solver/_index.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';
|
||||
|
||||
export const roll = async (message: DiscordenoMessage, args: string[], command: string) => {
|
||||
|
@ -66,7 +66,7 @@ export const roll = async (message: DiscordenoMessage, args: string[], command:
|
|||
|
||||
// If there was an error, report it to the user in hopes that they can determine what they did wrong
|
||||
if (returnmsg.error) {
|
||||
m.edit({embeds: [pubEmbedDetails.embed]});
|
||||
m.edit({ embeds: [pubEmbedDetails.embed] });
|
||||
|
||||
if (DEVMODE && config.logRolls) {
|
||||
// If enabled, log rolls so we can see what went wrong
|
||||
|
@ -78,7 +78,7 @@ export const roll = async (message: DiscordenoMessage, args: string[], command:
|
|||
// Determine if we are to send a GM roll or a normal roll
|
||||
if (modifiers.gmRoll) {
|
||||
// Send the public embed to correct channel
|
||||
m.edit({embeds: [pubEmbedDetails.embed]});
|
||||
m.edit({ embeds: [pubEmbedDetails.embed] });
|
||||
|
||||
// And message the full details to each of the GMs, alerting roller of every GM that could not be messaged
|
||||
modifiers.gms.forEach(async (gm) => {
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
// Log4Deno deps
|
||||
LT,
|
||||
} from '../../deps.ts';
|
||||
import { warnColor, generateStats } from '../commandUtils.ts';
|
||||
import { generateStats, warnColor } from '../commandUtils.ts';
|
||||
|
||||
export const stats = async (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
|
|
Loading…
Reference in New Issue