1
1
mirror of https://github.com/Burn-E99/TheArtificer.git synced 2026-06-04 09:03:50 -04:00
This commit is contained in:
Ean Milligan
2025-04-26 13:23:37 -04:00
parent 76e007e2e4
commit c7c974c395
39 changed files with 1938 additions and 1943 deletions

View File

@@ -18,22 +18,22 @@ import { optOut } from './optOut.ts';
import { optIn } from './optIn.ts';
export default {
ping,
rip,
rollHelp,
rollDecorators,
help,
info,
privacy,
version,
report,
stats,
api,
emoji,
roll,
handleMentions,
audit,
heatmap,
optOut,
optIn,
ping,
rip,
rollHelp,
rollDecorators,
help,
info,
privacy,
version,
report,
stats,
api,
emoji,
roll,
handleMentions,
audit,
heatmap,
optOut,
optIn,
};

View File

@@ -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).',
},
],
})

View File

@@ -5,9 +5,9 @@ import { status } from './status.ts';
import { showHideWarn } from './showHideWarn.ts';
export default {
help,
allowBlock,
deleteGuild,
status,
showHideWarn,
help,
allowBlock,
deleteGuild,
status,
showHideWarn,
};

View File

@@ -1,65 +1,65 @@
import config from '../../../config.ts';
import {
// Discordeno deps
DiscordenoMessage,
// Discordeno deps
DiscordenoMessage,
} from '../../../deps.ts';
import { infoColor1, infoColor2 } from '../../commandUtils.ts';
import utils from '../../utils.ts';
export const help = (message: DiscordenoMessage) => {
message.send({
embeds: [
{
color: infoColor2,
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.
message.send({
embeds: [
{
color: infoColor2,
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.
For information on how to use the API, please check the GitHub README for more information [here](https://github.com/Burn-E99/TheArtificer).
You may enable and disable the API rolls for your guild as needed.`,
},
{
color: infoColor1,
title: 'Available API Commands:',
fields: [
{
name: `\`${config.prefix}api help\``,
value: 'This command',
inline: true,
},
{
name: `\`${config.prefix}api status\``,
value: 'Shows the current status of the API for the channel this was run in',
inline: true,
},
{
name: `\`${config.prefix}api allow/enable\``,
value: 'Allows API Rolls to be sent to the channel this was run in',
inline: true,
},
{
name: `\`${config.prefix}api block/disable\``,
value: 'Blocks API Rolls from being sent to the channel this was run in',
inline: true,
},
{
name: `\`${config.prefix}api delete\``,
value: 'Deletes this channel\'s settings from The Artificer\'s database',
inline: true,
},
{
name: `\`${config.prefix}api show-warn\``,
value: 'Shows the API warning on all rolls sent to the channel this was run in',
inline: true,
},
{
name: `\`${config.prefix}api hide-warn\``,
value: 'Hides the API warning on all rolls sent to the channel this was run in',
inline: true,
},
],
},
],
}).catch((e: Error) => utils.commonLoggers.messageSendError('apiHelp.ts:67', message, e));
},
{
color: infoColor1,
title: 'Available API Commands:',
fields: [
{
name: `\`${config.prefix}api help\``,
value: 'This command',
inline: true,
},
{
name: `\`${config.prefix}api status\``,
value: 'Shows the current status of the API for the channel this was run in',
inline: true,
},
{
name: `\`${config.prefix}api allow/enable\``,
value: 'Allows API Rolls to be sent to the channel this was run in',
inline: true,
},
{
name: `\`${config.prefix}api block/disable\``,
value: 'Blocks API Rolls from being sent to the channel this was run in',
inline: true,
},
{
name: `\`${config.prefix}api delete\``,
value: "Deletes this channel's settings from The Artificer's database",
inline: true,
},
{
name: `\`${config.prefix}api show-warn\``,
value: 'Shows the API warning on all rolls sent to the channel this was run in',
inline: true,
},
{
name: `\`${config.prefix}api hide-warn\``,
value: 'Hides the API warning on all rolls sent to the channel this was run in',
inline: true,
},
],
},
],
}).catch((e: Error) => utils.commonLoggers.messageSendError('apiHelp.ts:67', message, e));
};

View File

@@ -3,7 +3,7 @@ import { auditDB } from './auditDB.ts';
import { auditGuilds } from './auditGuilds.ts';
export default {
auditHelp,
auditDB,
auditGuilds,
auditHelp,
auditDB,
auditGuilds,
};

View File

@@ -1,94 +1,94 @@
import config from '../../../config.ts';
import {
// Discordeno deps
cache,
cacheHandlers,
DiscordenoMessage,
// Discordeno deps
cache,
cacheHandlers,
DiscordenoMessage,
} from '../../../deps.ts';
import { infoColor2 } from '../../commandUtils.ts';
import utils from '../../utils.ts';
export const auditGuilds = async (message: DiscordenoMessage) => {
const cachedGuilds = await cacheHandlers.size('guilds');
let totalCount = 0;
let realCount = 0;
let botsCount = 0;
const cachedGuilds = await cacheHandlers.size('guilds');
let totalCount = 0;
let realCount = 0;
let botsCount = 0;
let auditText = '';
let auditText = '';
cache.guilds.forEach((guild) => {
totalCount += guild.memberCount;
let localBotCount = 0;
let localRealCount = 0;
guild.members.forEach((member) => {
if (member.bot) {
botsCount++;
localBotCount++;
} else {
realCount++;
localRealCount++;
}
});
cache.guilds.forEach((guild) => {
totalCount += guild.memberCount;
let localBotCount = 0;
let localRealCount = 0;
guild.members.forEach((member) => {
if (member.bot) {
botsCount++;
localBotCount++;
} else {
realCount++;
localRealCount++;
}
});
auditText += `Guild: ${guild.name} (${guild.id})
auditText += `Guild: ${guild.name} (${guild.id})
Owner: ${guild.owner?.username}#${guild.owner?.discriminator} (${guild.ownerId})
Tot mem: ${guild.memberCount} | Real: ${localRealCount} | Bot: ${localBotCount}
`;
});
});
const b = await new Blob([auditText as BlobPart], { 'type': 'text' });
const tooBig = await new Blob(['tooBig' as BlobPart], { 'type': 'text' });
const b = await new Blob([auditText as BlobPart], { 'type': 'text' });
const tooBig = await new Blob(['tooBig' as BlobPart], { 'type': 'text' });
message.send({
embeds: [{
color: infoColor2,
title: 'Guilds Audit',
description: `Shows details of the guilds that ${config.name} serves.
message.send({
embeds: [{
color: infoColor2,
title: 'Guilds Audit',
description: `Shows details of the guilds that ${config.name} serves.
Please see attached file for audit details on cached guilds and members.`,
timestamp: new Date().toISOString(),
fields: [
{
name: 'Total Guilds:',
value: `${cache.guilds.size}`,
inline: true,
},
{
name: 'Cached Guilds:',
value: `${cachedGuilds}`,
inline: true,
},
{
name: 'Uncached Guilds:',
value: `${cache.dispatchedGuildIds.size}`,
inline: true,
},
{
name: 'Total Members\n(may be artificially higher if 1 user is in multiple guilds the bot is in):',
value: `${totalCount}`,
inline: true,
},
{
name: 'Cached Real People:',
value: `${realCount}`,
inline: true,
},
{
name: 'Cached Bots:',
value: `${botsCount}`,
inline: true,
},
{
name: 'Average members per guild:',
value: `${(totalCount / cache.guilds.size).toFixed(2)}`,
inline: true,
},
],
}],
file: {
'blob': b.size > 8388290 ? tooBig : b,
'name': 'auditDetails.txt',
},
}).catch((e: Error) => utils.commonLoggers.messageSendError('auditGuild.ts:19', message, e));
timestamp: new Date().toISOString(),
fields: [
{
name: 'Total Guilds:',
value: `${cache.guilds.size}`,
inline: true,
},
{
name: 'Cached Guilds:',
value: `${cachedGuilds}`,
inline: true,
},
{
name: 'Uncached Guilds:',
value: `${cache.dispatchedGuildIds.size}`,
inline: true,
},
{
name: 'Total Members\n(may be artificially higher if 1 user is in multiple guilds the bot is in):',
value: `${totalCount}`,
inline: true,
},
{
name: 'Cached Real People:',
value: `${realCount}`,
inline: true,
},
{
name: 'Cached Bots:',
value: `${botsCount}`,
inline: true,
},
{
name: 'Average members per guild:',
value: `${(totalCount / cache.guilds.size).toFixed(2)}`,
inline: true,
},
],
}],
file: {
'blob': b.size > 8388290 ? tooBig : b,
'name': 'auditDetails.txt',
},
}).catch((e: Error) => utils.commonLoggers.messageSendError('auditGuild.ts:19', message, e));
};

View File

@@ -1,33 +1,33 @@
import config from '../../../config.ts';
import {
// Discordeno deps
DiscordenoMessage,
// Discordeno deps
DiscordenoMessage,
} from '../../../deps.ts';
import { infoColor1 } from '../../commandUtils.ts';
import utils from '../../utils.ts';
export const auditHelp = (message: DiscordenoMessage) => {
message.send({
embeds: [{
color: infoColor1,
title: 'Audit Help',
fields: [
{
name: `\`${config.prefix}audit help\``,
value: 'This command',
inline: true,
},
{
name: `\`${config.prefix}audit db\``,
value: 'Shows current DB table sizes',
inline: true,
},
{
name: `\`${config.prefix}audit guilds\``,
value: 'Shows breakdown of guilds and detials on them',
inline: true,
},
],
}],
}).catch((e: Error) => utils.commonLoggers.messageSendError('auditHelp.ts:35', message, e));
message.send({
embeds: [{
color: infoColor1,
title: 'Audit Help',
fields: [
{
name: `\`${config.prefix}audit help\``,
value: 'This command',
inline: true,
},
{
name: `\`${config.prefix}audit db\``,
value: 'Shows current DB table sizes',
inline: true,
},
{
name: `\`${config.prefix}audit guilds\``,
value: 'Shows breakdown of guilds and detials on them',
inline: true,
},
],
}],
}).catch((e: Error) => utils.commonLoggers.messageSendError('auditHelp.ts:35', message, e));
};

View File

@@ -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,
},
],

View File

@@ -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,

View File

@@ -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,

View File

@@ -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).

View File

@@ -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>{
apiRoll: false,
dd: { m, message },
rollCmd,
modifiers,
originalCommand,
});
queueRoll(
<QueuedRoll> {
apiRoll: false,
dd: { m, message },
rollCmd,
modifiers,
originalCommand,
},
);
} catch (e) {
log(LT.ERROR, `Undandled Error: ${JSON.stringify(e)}`);
}

View File

@@ -1,5 +1,5 @@
import { getModifiers } from './getModifiers.ts';
export default {
getModifiers,
getModifiers,
};

View File

@@ -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

View File

@@ -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,
},
{

View File

@@ -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,
},
],

View File

@@ -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);