update deno fmt, update std version, sonar fix

This commit is contained in:
Ean Milligan (Bastion) 2022-06-26 23:08:32 -04:00
parent a7cdd91969
commit c71f6f76e4
6 changed files with 77 additions and 73 deletions

View File

@ -1,63 +1,63 @@
export const config = {
"name": "The Artificer", // Name of the bot
"version": "2.0.0", // 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": 10000000, // 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.0.0', // 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': 10000000, // 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
'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
}
'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
'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
'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
}
'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
},
},
],
};
export default config;

View File

@ -6,7 +6,7 @@
},
"lint": {
"files": {
"include": ["src/", "db/", "mod.ts"],
"include": ["src/", "db/", "mod.ts", "deps.ts", "config.ts", "config.example.ts"],
"exclude": []
},
"rules": {
@ -17,7 +17,7 @@
},
"fmt": {
"files": {
"include": ["src/", "db/", "mod.ts"],
"include": ["src/", "db/", "mod.ts", "deps.ts", "config.ts", "config.example.ts"],
"exclude": []
},
"options": {

32
deps.ts
View File

@ -1,22 +1,26 @@
// All external dependancies are to be loaded here to make updating dependancy versions much easier
export {
startBot, editBotStatus, editBotNickname,
Intents, DiscordActivityTypes,
sendMessage, sendDirectMessage,
cache, cacheHandlers, botId,
hasGuildPermissions
} from "https://deno.land/x/discordeno@12.0.1/mod.ts";
botId,
cache,
cacheHandlers,
DiscordActivityTypes,
editBotNickname,
editBotStatus,
hasGuildPermissions,
Intents,
sendDirectMessage,
sendMessage,
startBot,
} from 'https://deno.land/x/discordeno@12.0.1/mod.ts';
export type {
DiscordenoMessage, DiscordenoGuild, CreateMessage, EmbedField
} from "https://deno.land/x/discordeno@12.0.1/mod.ts";
export type { CreateMessage, DiscordenoGuild, DiscordenoMessage, EmbedField } from 'https://deno.land/x/discordeno@12.0.1/mod.ts';
export { Client } from "https://deno.land/x/mysql@v2.10.2/mod.ts";
export { Client } from 'https://deno.land/x/mysql@v2.10.2/mod.ts';
export { Status, STATUS_TEXT } from "https://deno.land/std@0.137.0/http/http_status.ts";
export { Status, STATUS_TEXT } from 'https://deno.land/std@0.145.0/http/http_status.ts';
export { nanoid } from "https://deno.land/x/nanoid@v3.0.0/mod.ts";
export { nanoid } from 'https://deno.land/x/nanoid@v3.0.0/mod.ts';
export { LogTypes as LT, initLog, log } from "https://raw.githubusercontent.com/Burn-E99/Log4Deno/V1.1.1/mod.ts";
export { initLog, log, LogTypes as LT } from 'https://raw.githubusercontent.com/Burn-E99/Log4Deno/V1.1.1/mod.ts';
export * as is from "https://deno.land/x/imagescript@v1.2.13/mod.ts";
export * as is from 'https://deno.land/x/imagescript@v1.2.13/mod.ts';

View File

@ -10,7 +10,7 @@ export const heatmapPng = async (requestEvent: Deno.RequestEvent) => {
requestEvent.respondWith(
new Response(file, {
status: Status.OK,
statusText: STATUS_TEXT.get(Status.OK),
statusText: STATUS_TEXT[Status.OK],
}),
);
};

View File

@ -4,7 +4,7 @@ import {
STATUS_TEXT,
} from '../../deps.ts';
const genericResponse = (customText: string, status: Status) => new Response(customText || STATUS_TEXT.get(status), { status: status, statusText: STATUS_TEXT.get(status) });
const genericResponse = (customText: string, status: Status) => new Response(customText || STATUS_TEXT[status], { status: status, statusText: STATUS_TEXT[status] });
export default {
BadRequest: (customText: string) => genericResponse(customText, Status.BadRequest),

View File

@ -8,7 +8,7 @@ import {
// Discordeno deps
cache,
cacheHandlers,
// imagescript
// imagescript dep
is,
// Log4Deno deps
log,
@ -160,9 +160,9 @@ const updateHeatmapPng = async () => {
let minRollCnt = Infinity;
let maxRollCnt = 0;
// determine min and max values
for (let hour = 0; hour < heatmapData.length; hour++) {
for (let day = 0; day < weekDays.length; day++) {
const rollCnt = heatmapData[hour][weekDays[day]];
for (const hour of heatmapData) {
for (const day of weekDays) {
const rollCnt = hour[day];
log(LT.LOG, `updateHeatmapPng | finding min/max | min: ${minRollCnt} max: ${maxRollCnt} curr: ${rollCnt}`);
if (rollCnt > maxRollCnt) {
maxRollCnt = rollCnt;