deno fmt
This commit is contained in:
parent
76e007e2e4
commit
c7c974c395
|
@ -1,60 +1,70 @@
|
|||
export const config = {
|
||||
'name': 'The Artificer', // Name of the bot
|
||||
'version': '2.1.3', // Version of the bot
|
||||
'token': 'the_bot_token', // Discord API Token for this bot
|
||||
'localtoken': 'local_testing_token', // Discord API Token for a secondary OPTIONAL testing bot, THIS MUST BE DIFFERENT FROM "token"
|
||||
'prefix': '[[', // Prefix for all commands
|
||||
'postfix': ']]', // Postfix for rolling command
|
||||
'limits': { // Limits for the bot functions
|
||||
'maxLoops': 5000000, // Determines how long the bot will attempt a roll, number of loops before it kills a roll. Increase this at your own risk, originally was set to 5 Million before rollWorkers were added, increased to 10 Million since multiple rolls can be handled concurrently
|
||||
'maxWorkers': 16, // Maximum number of worker threads to spawn at once (Set this to less than the number of threads your CPU has, Artificer will eat it all if too many rolls happen at once)
|
||||
'workerTimeout': 300000, // Maximum time before the bot kills a worker thread in ms
|
||||
name: 'The Artificer', // Name of the bot
|
||||
version: '2.1.3', // Version of the bot
|
||||
token: 'the_bot_token', // Discord API Token for this bot
|
||||
localtoken: 'local_testing_token', // Discord API Token for a secondary OPTIONAL testing bot, THIS MUST BE DIFFERENT FROM "token"
|
||||
prefix: '[[', // Prefix for all commands
|
||||
postfix: ']]', // Postfix for rolling command
|
||||
limits: {
|
||||
// Limits for the bot functions
|
||||
maxLoops: 5000000, // Determines how long the bot will attempt a roll, number of loops before it kills a roll. Increase this at your own risk, originally was set to 5 Million before rollWorkers were added, increased to 10 Million since multiple rolls can be handled concurrently
|
||||
maxWorkers: 16, // Maximum number of worker threads to spawn at once (Set this to less than the number of threads your CPU has, Artificer will eat it all if too many rolls happen at once)
|
||||
workerTimeout: 300000, // Maximum time before the bot kills a worker thread in ms
|
||||
},
|
||||
'api': { // Setting for the built-in API
|
||||
'enable': false, // Leave this off if you have no intention of using this/supporting it
|
||||
'publicDomain': 'http://example.com/', // Public domain that the API is behind, should end with a /
|
||||
'port': 8080, // Port for the API to listen on
|
||||
'supportURL': 'your_support_url_for_api_abuse', // Fill this in with the way you wish to be contacted when somebody needs to report API key abuse
|
||||
'rateLimitTime': 10000, // Time range for how often the API rate limits will be lifted (time in ms)
|
||||
'rateLimitCnt': 10, // Amount of requests that can be made (successful or not) during above time range before getting rate limited
|
||||
'admin': 0n, // Discord user ID of the bot admin, this user will be the user that can ban/unban user/channel combos and API keys
|
||||
'adminKey': 'your_25char_api_token', // API Key generated by nanoid that is 25 char long, this gets pre-populated into all_keys
|
||||
'email': 0n, // Temporary set up for email, this will be adjusted to an actual email using deno-smtp in the future.
|
||||
api: {
|
||||
// Setting for the built-in API
|
||||
enable: false, // Leave this off if you have no intention of using this/supporting it
|
||||
publicDomain: 'http://example.com/', // Public domain that the API is behind, should end with a /
|
||||
port: 8080, // Port for the API to listen on
|
||||
supportURL: 'your_support_url_for_api_abuse', // Fill this in with the way you wish to be contacted when somebody needs to report API key abuse
|
||||
rateLimitTime: 10000, // Time range for how often the API rate limits will be lifted (time in ms)
|
||||
rateLimitCnt: 10, // Amount of requests that can be made (successful or not) during above time range before getting rate limited
|
||||
admin: 0n, // Discord user ID of the bot admin, this user will be the user that can ban/unban user/channel combos and API keys
|
||||
adminKey: 'your_25char_api_token', // API Key generated by nanoid that is 25 char long, this gets pre-populated into all_keys
|
||||
email: 0n, // Temporary set up for email, this will be adjusted to an actual email using deno-smtp in the future.
|
||||
},
|
||||
'db': { // Settings for the MySQL database, this is required for use with the API, if you do not want to set this up, you will need to rip all code relating to the DB out of the bot
|
||||
'host': '', // IP address for the db, usually localhost
|
||||
'localhost': '', // IP address for a secondary OPTIONAL local testing DB, usually also is localhost, but depends on your dev environment
|
||||
'port': 3306, // Port for the db
|
||||
'username': '', // Username for the account that will access your DB, this account will need "DB Manager" admin rights and "REFERENCES" Global Privalages
|
||||
'password': '', // Password for the account, user account may need to be authenticated with the "Standard" Authentication Type if this does not work out of the box
|
||||
'name': '', // Name of the database Schema to use for the bot
|
||||
db: {
|
||||
// Settings for the MySQL database, this is required for use with the API, if you do not want to set this up, you will need to rip all code relating to the DB out of the bot
|
||||
host: '', // IP address for the db, usually localhost
|
||||
localhost: '', // IP address for a secondary OPTIONAL local testing DB, usually also is localhost, but depends on your dev environment
|
||||
port: 3306, // Port for the db
|
||||
username: '', // Username for the account that will access your DB, this account will need "DB Manager" admin rights and "REFERENCES" Global Privalages
|
||||
password: '', // Password for the account, user account may need to be authenticated with the "Standard" Authentication Type if this does not work out of the box
|
||||
name: '', // Name of the database Schema to use for the bot
|
||||
},
|
||||
'logRolls': false, // Enables logging of roll commands, this should be left disabled for privacy, but exists to allow verification of rolls before deployment, all API rolls will always be logged no matter what this is set to
|
||||
'logChannel': 0n, // Discord channel ID where the bot should put startup messages and other error messages needed
|
||||
'reportChannel': 0n, // Discord channel ID where reports will be sent when using the built-in report command
|
||||
'devServer': 0n, // Discord guild ID where testing of indev features/commands will be handled, used in conjuction with the DEVMODE bool in mod.ts
|
||||
'emojis': [ // Array of objects containing all emojis that the bot can send on your behalf, empty this array if you don't want any of them
|
||||
{ // Emoji object, duplicate for each emoji
|
||||
'name': 'emoji_name', // Name of emoji in discord
|
||||
'aliases': ['alias_1', 'alias_2', 'alias_n'], // Commands that will activate this emoji
|
||||
'id': 'the_emoji_id', // Discord emoji ID for this emoji
|
||||
'animated': false, // Tells the bot this emoji is animated so it sends correctly
|
||||
'deleteSender': false, // Tells the bot to attempt to delete the sender's message after sending the emoji
|
||||
logRolls: false, // Enables logging of roll commands, this should be left disabled for privacy, but exists to allow verification of rolls before deployment, all API rolls will always be logged no matter what this is set to
|
||||
logChannel: 0n, // Discord channel ID where the bot should put startup messages and other error messages needed
|
||||
reportChannel: 0n, // Discord channel ID where reports will be sent when using the built-in report command
|
||||
devServer: 0n, // Discord guild ID where testing of indev features/commands will be handled, used in conjuction with the DEVMODE bool in mod.ts
|
||||
emojis: [
|
||||
// Array of objects containing all emojis that the bot can send on your behalf, empty this array if you don't want any of them
|
||||
{
|
||||
// Emoji object, duplicate for each emoji
|
||||
name: 'emoji_name', // Name of emoji in discord
|
||||
aliases: ['alias_1', 'alias_2', 'alias_n'], // Commands that will activate this emoji
|
||||
id: 'the_emoji_id', // Discord emoji ID for this emoji
|
||||
animated: false, // Tells the bot this emoji is animated so it sends correctly
|
||||
deleteSender: false, // Tells the bot to attempt to delete the sender's message after sending the emoji
|
||||
},
|
||||
],
|
||||
'botLists': [ // Array of objects containing all bot lists that stats should be posted to
|
||||
{ // Bot List object, duplicate for each bot list
|
||||
'name': 'Bot List Name', // Name of bot list, not used
|
||||
'enabled': true, // Should statistics be posted to this list?
|
||||
'apiUrl': 'https://example.com/api/bots/?{bot_id}/stats', // API URL, use ?{bot_id} in place of the bot id so that it can be dynamically replaced
|
||||
'headers': [ // Array of headers that need to be added to the request
|
||||
{ // Header Object, duplicate for every header needed
|
||||
'header': 'header_name', // Name of header needed, usually Authorization is needed
|
||||
'value': 'header_value', // Value for the header
|
||||
botLists: [
|
||||
// Array of objects containing all bot lists that stats should be posted to
|
||||
{
|
||||
// Bot List object, duplicate for each bot list
|
||||
name: 'Bot List Name', // Name of bot list, not used
|
||||
enabled: true, // Should statistics be posted to this list?
|
||||
apiUrl: 'https://example.com/api/bots/?{bot_id}/stats', // API URL, use ?{bot_id} in place of the bot id so that it can be dynamically replaced
|
||||
headers: [
|
||||
// Array of headers that need to be added to the request
|
||||
{
|
||||
// Header Object, duplicate for every header needed
|
||||
header: 'header_name', // Name of header needed, usually Authorization is needed
|
||||
value: 'header_value', // Value for the header
|
||||
},
|
||||
],
|
||||
'body': { // Data payload to send to the bot list, will be turned into a string and any ?{} will be replaced with the required value, currently only has ?{server_count}
|
||||
'param_name': '?{param_value}', // Add more params as needed
|
||||
body: {
|
||||
// Data payload to send to the bot list, will be turned into a string and any ?{} will be replaced with the required value, currently only has ?{server_count}
|
||||
param_name: '?{param_value}', // Add more params as needed
|
||||
},
|
||||
},
|
||||
],
|
||||
|
|
4
mod.ts
4
mod.ts
|
@ -74,9 +74,7 @@ startBot({
|
|||
}, 30000);
|
||||
|
||||
// Interval to update bot list stats every 24 hours
|
||||
LOCALMODE
|
||||
? log(LT.INFO, 'updateListStatistics not running')
|
||||
: setInterval(() => {
|
||||
LOCALMODE ? log(LT.INFO, 'updateListStatistics not running') : setInterval(() => {
|
||||
log(LT.LOG, 'Updating all bot lists statistics');
|
||||
intervals.updateListStatistics(botId, cache.guilds.size + cache.dispatchedGuildIds.size);
|
||||
}, 86400000);
|
||||
|
|
|
@ -33,7 +33,7 @@ export const generateReport = (msg: string) => ({
|
|||
export const generateStats = (guildCount: number, channelCount: number, memberCount: number, rollCount: bigint, utilityCount: bigint, rollRate: number, utilityRate: number) => ({
|
||||
embeds: [{
|
||||
color: infoColor2,
|
||||
title: 'The Artificer\'s Statistics:',
|
||||
title: "The Artificer's Statistics:",
|
||||
timestamp: new Date().toISOString(),
|
||||
fields: [
|
||||
{
|
||||
|
|
|
@ -74,8 +74,7 @@ export const api = async (message: DiscordenoMessage, args: string[]) => {
|
|||
{
|
||||
color: failColor,
|
||||
title: 'API commands are powerful and can only be used by guild Owners and Admins.',
|
||||
description:
|
||||
'For information on how to use the API, please check the GitHub README for more information [here](https://github.com/Burn-E99/TheArtificer).',
|
||||
description: 'For information on how to use the API, please check the GitHub README for more information [here](https://github.com/Burn-E99/TheArtificer).',
|
||||
},
|
||||
],
|
||||
})
|
||||
|
|
|
@ -11,7 +11,7 @@ export const help = (message: DiscordenoMessage) => {
|
|||
embeds: [
|
||||
{
|
||||
color: infoColor2,
|
||||
title: 'The Artificer\'s API Details:',
|
||||
title: "The Artificer's API Details:",
|
||||
description:
|
||||
`The Artificer 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.
|
||||
|
||||
|
@ -45,7 +45,7 @@ You may enable and disable the API rolls for your guild as needed.`,
|
|||
},
|
||||
{
|
||||
name: `\`${config.prefix}api delete\``,
|
||||
value: 'Deletes this channel\'s settings from The Artificer\'s database',
|
||||
value: "Deletes this channel's settings from The Artificer's database",
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -91,7 +91,8 @@ export const help = (message: DiscordenoMessage) => {
|
|||
},
|
||||
{
|
||||
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,
|
||||
},
|
||||
],
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import config from '../../config.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries, ignoreList } from '../db/common.ts';
|
||||
import { ignoreList, queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import config from '../../config.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries, ignoreList } from '../db/common.ts';
|
||||
import { ignoreList, queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
|
|
|
@ -21,7 +21,8 @@ export const privacy = (message: DiscordenoMessage) => {
|
|||
fields: [
|
||||
{
|
||||
name: 'The Artificer 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 The Artificer 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 The Artificer can see.
|
||||
|
||||
For more details, please check out the Privacy Policy on the GitHub [here](https://github.com/Burn-E99/TheArtificer/blob/master/PRIVACY.md).
|
||||
|
||||
|
|
|
@ -53,13 +53,15 @@ export const roll = async (message: DiscordenoMessage, args: string[], command:
|
|||
// Rejoin all of the args and send it into the solver, if solver returns a falsy item, an error object will be substituded in
|
||||
const rollCmd = message.content.substring(2);
|
||||
|
||||
queueRoll(<QueuedRoll>{
|
||||
queueRoll(
|
||||
<QueuedRoll> {
|
||||
apiRoll: false,
|
||||
dd: { m, message },
|
||||
rollCmd,
|
||||
modifiers,
|
||||
originalCommand,
|
||||
});
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
log(LT.ERROR, `Undandled Error: ${JSON.stringify(e)}`);
|
||||
}
|
||||
|
|
|
@ -64,9 +64,7 @@ export const getModifiers = (m: DiscordenoMessage, args: string[], command: stri
|
|||
}
|
||||
if (modifiers.gms.length < 1) {
|
||||
// If -gm is on and none were found, throw an error
|
||||
m.edit(generateRollError(errorType, 'Must specifiy at least one GM by @mentioning them')).catch((e) =>
|
||||
utils.commonLoggers.messageEditError('getModifiers.ts:66', m, e)
|
||||
);
|
||||
m.edit(generateRollError(errorType, 'Must specifiy at least one GM by @mentioning them')).catch((e) => utils.commonLoggers.messageEditError('getModifiers.ts:66', m, e));
|
||||
|
||||
if (DEVMODE && config.logRolls) {
|
||||
// If enabled, log rolls so we can verify the bots math
|
||||
|
@ -83,9 +81,7 @@ export const getModifiers = (m: DiscordenoMessage, args: string[], command: stri
|
|||
|
||||
if (!args[i] || (args[i].toLowerCase()[0] !== 'd' && args[i].toLowerCase()[0] !== 'a')) {
|
||||
// If -o is on and asc or desc was not specified, error out
|
||||
m.edit(generateRollError(errorType, 'Must specifiy `a` or `d` to order the rolls ascending or descending')).catch((e) =>
|
||||
utils.commonLoggers.messageEditError('getModifiers.ts:81', m, e)
|
||||
);
|
||||
m.edit(generateRollError(errorType, 'Must specifiy `a` or `d` to order the rolls ascending or descending')).catch((e) => utils.commonLoggers.messageEditError('getModifiers.ts:81', m, e));
|
||||
|
||||
if (DEVMODE && config.logRolls) {
|
||||
// If enabled, log rolls so we can verify the bots math
|
||||
|
@ -112,9 +108,7 @@ export const getModifiers = (m: DiscordenoMessage, args: string[], command: stri
|
|||
|
||||
// maxRoll and nominalRoll cannot both be on, throw an error
|
||||
if (modifiers.maxRoll && modifiers.nominalRoll) {
|
||||
m.edit(generateRollError(errorType, 'Cannot maximise and nominise the roll at the same time')).catch((e) =>
|
||||
utils.commonLoggers.messageEditError('getModifiers.ts:106', m, e)
|
||||
);
|
||||
m.edit(generateRollError(errorType, 'Cannot maximise and nominise the roll at the same time')).catch((e) => utils.commonLoggers.messageEditError('getModifiers.ts:106', m, e));
|
||||
|
||||
if (DEVMODE && config.logRolls) {
|
||||
// If enabled, log rolls so we can verify the bots math
|
||||
|
|
|
@ -49,8 +49,7 @@ Examples: \`${config.prefix}d20${config.postfix} -nd\`, \`${config.prefix}d20${c
|
|||
},
|
||||
{
|
||||
name: '`-gm @user1 @user2 @usern` - GM Roll',
|
||||
value:
|
||||
'Rolls the requested roll in GM mode, suppressing all publicly shown results and details and sending the results directly to the specified GMs',
|
||||
value: '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,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -72,32 +72,27 @@ Additionally, replace \`x\` with \`F\` to roll Fate dice`,
|
|||
},
|
||||
{
|
||||
name: '`r<q` [Optional]',
|
||||
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`',
|
||||
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`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`r>q` [Optional]',
|
||||
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`',
|
||||
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`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`roa` or `ro=q` [Optional]',
|
||||
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`',
|
||||
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`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`ro<q` [Optional]',
|
||||
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`',
|
||||
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`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`ro>q` [Optional]',
|
||||
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`',
|
||||
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`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
|
@ -192,32 +187,27 @@ Additionally, replace \`x\` with \`F\` to roll Fate dice`,
|
|||
},
|
||||
{
|
||||
name: '`!p>u` [Optional]',
|
||||
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',
|
||||
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',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!p<u` [Optional]',
|
||||
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',
|
||||
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',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!!=u` [Optional]',
|
||||
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',
|
||||
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',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!!>u` [Optional]',
|
||||
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',
|
||||
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',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!!<u` [Optional]',
|
||||
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',
|
||||
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',
|
||||
inline: true,
|
||||
},
|
||||
],
|
||||
|
|
|
@ -40,8 +40,8 @@ export const stats = async (message: DiscordenoMessage) => {
|
|||
rolls,
|
||||
total - rolls,
|
||||
rollRate,
|
||||
totalRate - rollRate
|
||||
)
|
||||
totalRate - rollRate,
|
||||
),
|
||||
).catch((e: Error) => utils.commonLoggers.messageEditError('stats.ts:38', m, e));
|
||||
} catch (e) {
|
||||
utils.commonLoggers.messageSendError('stats.ts:41', message, e);
|
||||
|
|
|
@ -15,7 +15,7 @@ export const apiKeyDelete = async (
|
|||
query: Map<string, string>,
|
||||
apiUserid: BigInt,
|
||||
apiUserEmail: string,
|
||||
apiUserDelCode: string
|
||||
apiUserDelCode: string,
|
||||
) => {
|
||||
if (query.has('user') && (query.get('user') || '').length > 0 && query.has('email') && (query.get('email') || '').length > 0) {
|
||||
if (apiUserid === BigInt(query.get('user') || '0') && apiUserEmail === query.get('email')) {
|
||||
|
|
|
@ -103,13 +103,15 @@ export const apiRoll = async (requestEvent: Deno.RequestEvent, query: Map<string
|
|||
};
|
||||
|
||||
// Parse the roll and get the return text
|
||||
await queueRoll(<QueuedRoll>{
|
||||
await queueRoll(
|
||||
<QueuedRoll> {
|
||||
apiRoll: true,
|
||||
api: { requestEvent, channelId: BigInt(query.get('channel') || '0'), userId: BigInt(query.get('user') || '') },
|
||||
rollCmd,
|
||||
modifiers,
|
||||
originalCommand,
|
||||
});
|
||||
},
|
||||
);
|
||||
} catch (err) {
|
||||
// Handle any errors we missed
|
||||
log(LT.ERROR, `Unhandled Error: ${JSON.stringify(err)}`);
|
||||
|
@ -119,8 +121,8 @@ export const apiRoll = async (requestEvent: Deno.RequestEvent, query: Map<string
|
|||
// Alert API user that they messed up
|
||||
requestEvent.respondWith(
|
||||
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 {
|
||||
|
|
|
@ -14,6 +14,6 @@ export const heatmapPng = async (requestEvent: Deno.RequestEvent) => {
|
|||
status: STATUS_CODE.OK,
|
||||
statusText: STATUS_TEXT[STATUS_CODE.OK],
|
||||
headers: imageHeaders,
|
||||
})
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
import {
|
||||
// httpd deps
|
||||
StatusCode,
|
||||
STATUS_CODE,
|
||||
STATUS_TEXT,
|
||||
// httpd deps
|
||||
StatusCode,
|
||||
} from '../../deps.ts';
|
||||
|
||||
const genericResponse = (customText: string, status: StatusCode) =>
|
||||
new Response(customText || STATUS_TEXT[status], { status: status, statusText: STATUS_TEXT[status] });
|
||||
const genericResponse = (customText: string, status: StatusCode) => new Response(customText || STATUS_TEXT[status], { status: status, statusText: STATUS_TEXT[status] });
|
||||
|
||||
export default {
|
||||
BadRequest: (customText: string) => genericResponse(customText, STATUS_CODE.BadRequest),
|
||||
|
|
|
@ -196,7 +196,7 @@ const updateHeatmapPng = async () => {
|
|||
hourPixels[hour][0] + 1,
|
||||
dayPixels[day][1] - dayPixels[day][0] + 1,
|
||||
hourPixels[hour][1] - hourPixels[hour][0] + 1,
|
||||
is.Image.rgbToColor(255 * (1 - percent), 255 * percent, 0)
|
||||
is.Image.rgbToColor(255 * (1 - percent), 255 * percent, 0),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,12 +43,12 @@ const handleRollWorker = async (rq: QueuedRoll) => {
|
|||
(
|
||||
await generateRollEmbed(
|
||||
rq.dd.message.authorId,
|
||||
<SolvedRoll>{
|
||||
<SolvedRoll> {
|
||||
error: true,
|
||||
errorCode: 'TooComplex',
|
||||
errorMsg: 'Error: Roll took too long to process, try breaking roll down into simpler parts',
|
||||
},
|
||||
<RollModifiers>{}
|
||||
<RollModifiers> {},
|
||||
)
|
||||
).embed,
|
||||
],
|
||||
|
@ -175,9 +175,9 @@ const handleRollWorker = async (rq: QueuedRoll) => {
|
|||
}
|
||||
: {
|
||||
details: pubEmbedDetails,
|
||||
}
|
||||
)
|
||||
)
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ The results for this roll will replace this message when it is done.`,
|
|||
setInterval(async () => {
|
||||
log(
|
||||
LT.LOG,
|
||||
`Checking rollQueue for items, rollQueue length: ${rollQueue.length}, currentWorkers: ${currentWorkers}, config.limits.maxWorkers: ${config.limits.maxWorkers}`
|
||||
`Checking rollQueue for items, rollQueue length: ${rollQueue.length}, currentWorkers: ${currentWorkers}, config.limits.maxWorkers: ${config.limits.maxWorkers}`,
|
||||
);
|
||||
if (rollQueue.length && currentWorkers < config.limits.maxWorkers) {
|
||||
const temp = rollQueue.shift();
|
||||
|
|
Loading…
Reference in New Issue