deno fmt
This commit is contained in:
parent
aa7814d1fe
commit
65a182cb50
17
mod.ts
17
mod.ts
|
@ -3,18 +3,7 @@
|
||||||
*
|
*
|
||||||
* December 21, 2020
|
* December 21, 2020
|
||||||
*/
|
*/
|
||||||
import {
|
import { botId, cache, DiscordActivityTypes, DiscordenoGuild, DiscordenoMessage, editBotNickname, editBotStatus, Intents, sendMessage, startBot } from '@discordeno';
|
||||||
botId,
|
|
||||||
cache,
|
|
||||||
DiscordActivityTypes,
|
|
||||||
DiscordenoGuild,
|
|
||||||
DiscordenoMessage,
|
|
||||||
editBotNickname,
|
|
||||||
editBotStatus,
|
|
||||||
Intents,
|
|
||||||
sendMessage,
|
|
||||||
startBot,
|
|
||||||
} from '@discordeno';
|
|
||||||
import { initLog, log, LogTypes as LT } from '@Log4Deno';
|
import { initLog, log, LogTypes as LT } from '@Log4Deno';
|
||||||
|
|
||||||
import config from '~config';
|
import config from '~config';
|
||||||
|
@ -83,9 +72,7 @@ startBot({
|
||||||
}, 30000);
|
}, 30000);
|
||||||
|
|
||||||
// Interval to update bot list stats every 24 hours
|
// Interval to update bot list stats every 24 hours
|
||||||
LOCALMODE
|
LOCALMODE ? log(LT.INFO, 'updateListStatistics not running') : setInterval(() => {
|
||||||
? log(LT.INFO, 'updateListStatistics not running')
|
|
||||||
: setInterval(() => {
|
|
||||||
log(LT.LOG, 'Updating all bot lists statistics');
|
log(LT.LOG, 'Updating all bot lists statistics');
|
||||||
intervals.updateListStatistics(botId, cache.guilds.size + cache.dispatchedGuildIds.size);
|
intervals.updateListStatistics(botId, cache.guilds.size + cache.dispatchedGuildIds.size);
|
||||||
}, 86400000);
|
}, 86400000);
|
||||||
|
|
|
@ -32,7 +32,7 @@ export const onWorkerComplete = async (workerMessage: MessageEvent<SolvedRoll>,
|
||||||
const pubEmbedDetails = await generateRollEmbed(
|
const pubEmbedDetails = await generateRollEmbed(
|
||||||
rollRequest.apiRoll ? rollRequest.api.userId : rollRequest.dd.originalMessage.authorId,
|
rollRequest.apiRoll ? rollRequest.api.userId : rollRequest.dd.originalMessage.authorId,
|
||||||
returnMsg,
|
returnMsg,
|
||||||
rollRequest.modifiers
|
rollRequest.modifiers,
|
||||||
);
|
);
|
||||||
const gmEmbedDetails = await generateRollEmbed(rollRequest.apiRoll ? rollRequest.api.userId : rollRequest.dd.originalMessage.authorId, returnMsg, {
|
const gmEmbedDetails = await generateRollEmbed(rollRequest.apiRoll ? rollRequest.api.userId : rollRequest.dd.originalMessage.authorId, returnMsg, {
|
||||||
...rollRequest.modifiers,
|
...rollRequest.modifiers,
|
||||||
|
@ -148,9 +148,9 @@ export const onWorkerComplete = async (workerMessage: MessageEvent<SolvedRoll>,
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
details: pubEmbedDetails,
|
details: pubEmbedDetails,
|
||||||
}
|
},
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,12 +24,12 @@ export const terminateWorker = async (rollWorker: Worker, rollRequest: QueuedRol
|
||||||
(
|
(
|
||||||
await generateRollEmbed(
|
await generateRollEmbed(
|
||||||
rollRequest.dd.originalMessage.authorId,
|
rollRequest.dd.originalMessage.authorId,
|
||||||
<SolvedRoll>{
|
<SolvedRoll> {
|
||||||
error: true,
|
error: true,
|
||||||
errorCode: 'TooComplex',
|
errorCode: 'TooComplex',
|
||||||
errorMsg: 'Error: Roll took too long to process, try breaking roll down into simpler parts',
|
errorMsg: 'Error: Roll took too long to process, try breaking roll down into simpler parts',
|
||||||
},
|
},
|
||||||
<RollModifiers>{}
|
<RollModifiers> {},
|
||||||
)
|
)
|
||||||
).embed,
|
).embed,
|
||||||
],
|
],
|
||||||
|
|
|
@ -41,9 +41,7 @@ The results for this roll will replace this message when it is done.`,
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
log(
|
log(
|
||||||
LT.LOG,
|
LT.LOG,
|
||||||
`Checking rollQueue for items, rollQueue length: ${rollQueue.length}, currentWorkers: ${getWorkerCnt()}, config.limits.maxWorkers: ${
|
`Checking rollQueue for items, rollQueue length: ${rollQueue.length}, currentWorkers: ${getWorkerCnt()}, config.limits.maxWorkers: ${config.limits.maxWorkers}`,
|
||||||
config.limits.maxWorkers
|
|
||||||
}`
|
|
||||||
);
|
);
|
||||||
if (rollQueue.length && getWorkerCnt() < config.limits.maxWorkers) {
|
if (rollQueue.length && getWorkerCnt() < config.limits.maxWorkers) {
|
||||||
const rollRequest = rollQueue.shift();
|
const rollRequest = rollQueue.shift();
|
||||||
|
|
|
@ -13,7 +13,8 @@ export const help = (message: DiscordenoMessage) => {
|
||||||
{
|
{
|
||||||
color: infoColor2,
|
color: infoColor2,
|
||||||
title: `${config.name}'s API Details:`,
|
title: `${config.name}'s API Details:`,
|
||||||
description: `${config.name} has a built in API that allows user to roll dice into Discord using third party programs. By default, API rolls are blocked from being sent in your guild. The API warning is also enabled by default. These commands may only be used by the Owner or Admins of your guild.
|
description:
|
||||||
|
`${config.name} has a built in API that allows user to roll dice into Discord using third party programs. By default, API rolls are blocked from being sent in your guild. The API warning is also enabled by default. These commands may only be used by the Owner or Admins of your guild.
|
||||||
|
|
||||||
For information on how to use the API, please check the GitHub README for more information [here](${config.links.sourceCode}).
|
For information on how to use the API, please check the GitHub README for more information [here](${config.links.sourceCode}).
|
||||||
|
|
||||||
|
|
|
@ -120,23 +120,19 @@ Please see attached file for audit details on cached guilds and members.`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Repeat Guild Owners:',
|
name: 'Repeat Guild Owners:',
|
||||||
value:
|
value: repeatCounts
|
||||||
repeatCounts
|
|
||||||
.map((ownerCnt, serverIdx) => `${ownerCnt} ${ownerCnt === 1 ? 'person has' : 'people have'} me in ${serverIdx + 1} of their guilds`)
|
.map((ownerCnt, serverIdx) => `${ownerCnt} ${ownerCnt === 1 ? 'person has' : 'people have'} me in ${serverIdx + 1} of their guilds`)
|
||||||
.filter((str) => str)
|
.filter((str) => str)
|
||||||
.join('\n') || 'No Repeat Guild Owners',
|
.join('\n') || 'No Repeat Guild Owners',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Guild Size Dist:',
|
name: 'Guild Size Dist:',
|
||||||
value:
|
value: Array.from(guildSizeDist)
|
||||||
Array.from(guildSizeDist)
|
|
||||||
.map(
|
.map(
|
||||||
([size, count], idx) =>
|
([size, count], idx) =>
|
||||||
`${count} Guild${count === 1 ? ' has' : 's have'} ${
|
`${count} Guild${count === 1 ? ' has' : 's have'} ${
|
||||||
guildSizeDist.has(sizeCats[idx - 1])
|
guildSizeDist.has(sizeCats[idx - 1]) ? `${size.toLocaleString()} - ${(sizeCats[idx - 1] - 1).toLocaleString()}` : `at least ${size.toLocaleString()}`
|
||||||
? `${size.toLocaleString()} - ${(sizeCats[idx - 1] - 1).toLocaleString()}`
|
} Member${size === 1 ? '' : 's'}`,
|
||||||
: `at least ${size.toLocaleString()}`
|
|
||||||
} Member${size === 1 ? '' : 's'}`
|
|
||||||
)
|
)
|
||||||
.join('\n') || 'Not available',
|
.join('\n') || 'Not available',
|
||||||
},
|
},
|
||||||
|
|
|
@ -92,7 +92,8 @@ export const help = (message: DiscordenoMessage) => {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: `\`${config.prefix}xdydzracsq!${config.postfix}\` ...`,
|
name: `\`${config.prefix}xdydzracsq!${config.postfix}\` ...`,
|
||||||
value: `Rolls all configs requested, you may repeat the command multiple times in the same message (just ensure you close each roll with \`${config.postfix}\`), run \`${config.prefix}??\` for more details`,
|
value:
|
||||||
|
`Rolls all configs requested, you may repeat the command multiple times in the same message (just ensure you close each roll with \`${config.postfix}\`), run \`${config.prefix}??\` for more details`,
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -22,7 +22,8 @@ export const privacy = (message: DiscordenoMessage) => {
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: `${config.name} does not track or collect user information via Discord.`,
|
name: `${config.name} does not track or collect user information via Discord.`,
|
||||||
value: `The only user submitted information that is stored is submitted via the \`${config.prefix}report\` command. This information is only stored for a short period of time in a location that only the Developer of ${config.name} can see.
|
value:
|
||||||
|
`The only user submitted information that is stored is submitted via the \`${config.prefix}report\` command. This information is only stored for a short period of time in a location that only the Developer of ${config.name} can see.
|
||||||
|
|
||||||
For more details, please check out the Privacy Policy on the GitHub [here](${config.links.privacyPolicy}).
|
For more details, please check out the Privacy Policy on the GitHub [here](${config.links.privacyPolicy}).
|
||||||
|
|
||||||
|
|
|
@ -48,9 +48,7 @@ export const roll = async (message: DiscordenoMessage, args: string[], command:
|
||||||
|
|
||||||
// Return early if the modifiers were invalid
|
// Return early if the modifiers were invalid
|
||||||
if (!modifiers.valid) {
|
if (!modifiers.valid) {
|
||||||
m.edit(generateRollError('Modifiers invalid:', modifiers.error.name, modifiers.error.message)).catch((e) =>
|
m.edit(generateRollError('Modifiers invalid:', modifiers.error.name, modifiers.error.message)).catch((e) => utils.commonLoggers.messageEditError('roll.ts:50', m, e));
|
||||||
utils.commonLoggers.messageEditError('roll.ts:50', m, e)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (DEVMODE && config.logRolls) {
|
if (DEVMODE && config.logRolls) {
|
||||||
// If enabled, log rolls so we can verify the bots math
|
// If enabled, log rolls so we can verify the bots math
|
||||||
|
|
|
@ -55,8 +55,7 @@ Examples: \`${config.prefix}d20${config.postfix} -nd\`, \`${config.prefix}d20${c
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`-gm @user1 @user2 @userN` - GM Roll',
|
name: '`-gm @user1 @user2 @userN` - GM Roll',
|
||||||
value:
|
value: 'Rolls the requested roll in GM mode, suppressing all publicly shown results and details and sending the results directly to the specified GMs',
|
||||||
'Rolls the requested roll in GM mode, suppressing all publicly shown results and details and sending the results directly to the specified GMs',
|
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,32 +73,27 @@ Additionally, replace \`x\` with \`F\` to roll Fate dice`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`r<q` [Optional]',
|
name: '`r<q` [Optional]',
|
||||||
value:
|
value: 'Rerolls any rolls that are less than or equal to `a`, `r3` will reroll every die that land on 3, 2, or 1, throwing out old rolls, cannot be used with `ro`',
|
||||||
'Rerolls any rolls that are less than or equal to `a`, `r3` will reroll every die that land on 3, 2, or 1, throwing out old rolls, cannot be used with `ro`',
|
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`r>q` [Optional]',
|
name: '`r>q` [Optional]',
|
||||||
value:
|
value: 'Rerolls any rolls that are greater than or equal to `a`, `r3` will reroll every die that land on 3 or greater, throwing out old rolls, cannot be used with `ro`',
|
||||||
'Rerolls any rolls that are greater than or equal to `a`, `r3` will reroll every die that land on 3 or greater, throwing out old rolls, cannot be used with `ro`',
|
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`roa` or `ro=q` [Optional]',
|
name: '`roa` or `ro=q` [Optional]',
|
||||||
value:
|
value: 'Rerolls any rolls that match `a`, `ro3` will reroll each die that lands on 3 ONLY ONE TIME, throwing out old rolls, cannot be used with `r`',
|
||||||
'Rerolls any rolls that match `a`, `ro3` will reroll each die that lands on 3 ONLY ONE TIME, throwing out old rolls, cannot be used with `r`',
|
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`ro<q` [Optional]',
|
name: '`ro<q` [Optional]',
|
||||||
value:
|
value: 'Rerolls any rolls that are less than or equal to `a`, `ro3` will reroll each die that lands on 3, 2, or 1 ONLY ONE TIME, throwing out old rolls, cannot be used with `r`',
|
||||||
'Rerolls any rolls that are less than or equal to `a`, `ro3` will reroll each die that lands on 3, 2, or 1 ONLY ONE TIME, throwing out old rolls, cannot be used with `r`',
|
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`ro>q` [Optional]',
|
name: '`ro>q` [Optional]',
|
||||||
value:
|
value: 'Rerolls any rolls that are greater than or equal to `a`, `ro3` will reroll each die that lands on 3 or greater ONLY ONE TIME, throwing out old rolls, cannot be used with `r`',
|
||||||
'Rerolls any rolls that are greater than or equal to `a`, `ro3` will reroll each die that lands on 3 or greater ONLY ONE TIME, throwing out old rolls, cannot be used with `r`',
|
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -193,32 +188,27 @@ Additionally, replace \`x\` with \`F\` to roll Fate dice`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`!p>u` [Optional]',
|
name: '`!p>u` [Optional]',
|
||||||
value:
|
value: 'Penetrating Explosion on `u` and greater, rolls one `dy` for each die that lands on `u` or greater, but subtracts one from each resulting explosion',
|
||||||
'Penetrating Explosion on `u` and greater, rolls one `dy` for each die that lands on `u` or greater, but subtracts one from each resulting explosion',
|
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`!p<u` [Optional]',
|
name: '`!p<u` [Optional]',
|
||||||
value:
|
value: 'Penetrating Explosion on `u` and under, rolls one `dy` for each die that lands on `u` or under, but subtracts one from each resulting explosion',
|
||||||
'Penetrating Explosion on `u` and under, rolls one `dy` for each die that lands on `u` or under, but subtracts one from each resulting explosion',
|
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`!!=u` [Optional]',
|
name: '`!!=u` [Optional]',
|
||||||
value:
|
value: 'Compounding Explosion on `u`, rolls one `dy` for each die that lands on `u`, but adds the resulting explosion to the die that caused this explosion',
|
||||||
'Compounding Explosion on `u`, rolls one `dy` for each die that lands on `u`, but adds the resulting explosion to the die that caused this explosion',
|
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`!!>u` [Optional]',
|
name: '`!!>u` [Optional]',
|
||||||
value:
|
value: 'Compounding Explosion on `u` and greater, rolls one `dy` for each die that lands on `u` or greater, but adds the resulting explosion to the die that caused this explosion',
|
||||||
'Compounding Explosion on `u` and greater, rolls one `dy` for each die that lands on `u` or greater, but adds the resulting explosion to the die that caused this explosion',
|
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`!!<u` [Optional]',
|
name: '`!!<u` [Optional]',
|
||||||
value:
|
value: 'Compounding Explosion on `u` and under, rolls one `dy` for each die that lands on `u` or under, but adds the resulting explosion to the die that caused this explosion',
|
||||||
'Compounding Explosion on `u` and under, rolls one `dy` for each die that lands on `u` or under, but adds the resulting explosion to the die that caused this explosion',
|
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -116,7 +116,7 @@ export const apiRoll = async (query: Map<string, string>, apiUserid: bigint): Pr
|
||||||
} else {
|
} else {
|
||||||
// Alert API user that they messed up
|
// Alert API user that they messed up
|
||||||
return stdResp.Forbidden(
|
return stdResp.Forbidden(
|
||||||
`Verify you are a member of the guild you are sending this roll to. If you are, the ${config.name} may not have that registered, please send a message in the guild so ${config.name} can register this. This registration is temporary, so if you see this error again, just poke your server again.`
|
`Verify you are a member of the guild you are sending this roll to. If you are, the ${config.name} may not have that registered, please send a message in the guild so ${config.name} can register this. This registration is temporary, so if you see this error again, just poke your server again.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -197,7 +197,7 @@ const updateHeatmapPng = async () => {
|
||||||
hourPixels[hour][0] + 1,
|
hourPixels[hour][0] + 1,
|
||||||
dayPixels[day][1] - dayPixels[day][0] + 1,
|
dayPixels[day][1] - dayPixels[day][0] + 1,
|
||||||
hourPixels[hour][1] - hourPixels[hour][0] + 1,
|
hourPixels[hour][1] - hourPixels[hour][0] + 1,
|
||||||
Image.rgbToColor(255 * (1 - percent), 255 * percent, 0)
|
Image.rgbToColor(255 * (1 - percent), 255 * percent, 0),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue