Added !o !<>= and !o<>=, updated embeds to be more consistent, started coloring embeds

This commit is contained in:
Ean Milligan (Bastion) 2022-05-18 04:48:52 -04:00
parent 26b9309aa3
commit 733908f2c0
4 changed files with 167 additions and 110 deletions

View File

@ -81,7 +81,14 @@ The Artificer comes with a few supplemental commands to the main rolling command
| cfq or cf=q | Optional | Yes | changes crit fail to q | | cfq or cf=q | Optional | Yes | changes crit fail to q |
| cf<q | Optional | Yes | changes crit fail to be less than or equal to q | | cf<q | Optional | Yes | changes crit fail to be less than or equal to q |
| cf>q | Optional | Yes | changes crit fail to be greater than or equal to q | | cf>q | Optional | Yes | changes crit fail to be greater than or equal to q |
| ! | Optional | No | exploding, rolls another dy for every crit roll | | ! | Optional | No | exploding, rolls another dy for every crit success |
| !o | Optional | No | exploding once, rolls another dy for each original crit success |
| !=u | Optional | Yes | exploding, rolls another dy for every die that lands on u |
| !>u | Optional | Yes | exploding, rolls another dy for every die that lands on u or greater |
| !<u> | Optional | Yes | exploding, rolls another dy for every die that lands on u or less |
| !o=u | Optional | Yes | exploding once, rolls another dy for each original die that landed on u |
| !o>u | Optional | Yes | exploding once, rolls another dy for each original die that landed on u or greater |
| !o<u | Optional | Yes | exploding once, rolls another dy for each original die that landed on u or less |
* If the parameter is Required, it must be provided at all times. * If the parameter is Required, it must be provided at all times.
* If the parameter is Repeatable, it may occur multiple times in the roll configuration. * If the parameter is Repeatable, it may occur multiple times in the roll configuration.

View File

@ -86,9 +86,7 @@ export const getModifiers = (m: DiscordenoMessage, args: string[], command: stri
i--; i--;
break; break;
case "-o": case "-o":
console.log(args)
args.splice(i, 1); args.splice(i, 1);
console.log(args)
if (!args[i] || args[i].toLowerCase()[0] !== "d" && args[i].toLowerCase()[0] !== "a") { 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 // If -o is on and asc or desc was not specified, error out

View File

@ -1,12 +1,16 @@
import config from "../config.ts"; import config from "../config.ts";
const rollHelpColors = {
details: 0x6805e9,
decorators: 0x313bf9,
results: 0x0f8108
};
export const constantCmds = { export const constantCmds = {
apiDeleteFail: { apiDeleteFail: {
embeds: [{ embeds: [{
fields: [{ title: "Failed to delete this guild from the database.",
name: "Failed to delete this guild from the database.", description: "If this issue persists, please report this to the developers."
value: "If this issue persists, please report this to the developers."
}]
}] }]
}, },
apiGuildOnly: { apiGuildOnly: {
@ -17,18 +21,12 @@ export const constantCmds = {
apiHelp: { apiHelp: {
embeds: [ embeds: [
{ {
fields: [ 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.
name: "The Artificer's API Details:",
value: `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). 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.` You may enable and disable the API rolls for your guild as needed.`
}
]
}, { }, {
title: "Available API Commands:", title: "Available API Commands:",
fields: [ fields: [
@ -67,10 +65,8 @@ export const constantCmds = {
}, },
apiPermError: { apiPermError: {
embeds: [{ embeds: [{
fields: [{ title: "API commands are powerful and can only be used by guild Owners and Admins.",
name: "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)."
value: "For information on how to use the API, please check the GitHub README for more information [here](https://github.com/Burn-E99/TheArtificer)."
}]
}] }]
}, },
apiRemoveGuild: { apiRemoveGuild: {
@ -80,10 +76,8 @@ export const constantCmds = {
}, },
apiStatusFail: { apiStatusFail: {
embeds: [{ embeds: [{
fields: [{ title: "Failed to check API rolls status for this guild.",
name: "Failed to check API rolls status for this guild.", description: "If this issue persists, please report this to the developers."
value: "If this issue persists, please report this to the developers."
}]
}] }]
}, },
help: { help: {
@ -145,14 +139,12 @@ export const constantCmds = {
}, },
info: { info: {
embeds: [{ embeds: [{
fields: [{ title: "The Artificer, a Discord bot that specializing in rolling dice and calculating math",
name: "The Artificer, a Discord bot that specializing in rolling dice and calculating math", description: `The Artificer is developed by Ean AKA Burn_E99.
value: `The Artificer is developed by Ean AKA Burn_E99.
Additional information can be found on my website [here](https://discord.burne99.com/TheArtificer/). Additional information can be found on my website [here](https://discord.burne99.com/TheArtificer/).
Want to check out my source code? Check it out [here](https://github.com/Burn-E99/TheArtificer). Want to check out my source code? Check it out [here](https://github.com/Burn-E99/TheArtificer).
Need help with this bot? Join my support server [here](https://discord.gg/peHASXMZYv).` Need help with this bot? Join my support server [here](https://discord.gg/peHASXMZYv).`
}] }]
}]
}, },
loadingStats: { loadingStats: {
embeds: [{ embeds: [{
@ -183,43 +175,36 @@ export const constantCmds = {
}, },
report: { report: {
embeds: [{ embeds: [{
fields: [{ title: "Failed command has been reported to my developer.",
name: "Failed command has been reported to my developer.", description: `For more in depth support, and information about planned maintenance, please join the support server [here](https://discord.gg/peHASXMZYv).`
value: `For more in depth support, and information about planned maintenance, please join the support server [here](https://discord.gg/peHASXMZYv).`
}]
}] }]
}, },
reportFail: { reportFail: {
embeds: [{ embeds: [{
fields: [{ title: "Please provide a short description of what failed",
name: "Please provide a short description of what failed", description: "Providing a short description helps my developer quickly diagnose what went wrong."
value: "Providing a short description helps my developer quickly diagnose what went wrong."
}]
}] }]
}, },
rip: { rip: {
embeds: [{ embeds: [{
fields: [{ title: "The Artificer was built in memory of my Grandmother, Babka",
name: "The Artificer was built in memory of my Grandmother, Babka", description: `With much love, Ean
value: `With much love, Ean
December 21, 2020` December 21, 2020`
}] }]
}]
}, },
rollHelp: { rollHelp: {
embeds: [ embeds: [
{ {
color: rollHelpColors.details,
title: "The Artificer's Roll Command Details:", title: "The Artificer's Roll Command Details:",
fields: [ description: `You can chain as many of these options as you want, as long as the option does not disallow it.
{
name: "Details:",
value: `You can chain as many of these options as you want, as long as the option does not disallow it.
This command also can fully solve math equations with parenthesis. This command also can fully solve math equations with parenthesis.
The Artificer supports most of the [Roll20 formatting](https://artificer.eanm.dev/roll20). More details and examples can be found [here](https://artificer.eanm.dev/roll20).` The Artificer supports most of the [Roll20 formatting](https://artificer.eanm.dev/roll20). More details and examples can be found [here](https://artificer.eanm.dev/roll20).`,
}, { fields: [
{
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}\`)` 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}\`)`
}, { }, {
@ -296,55 +281,90 @@ export const constantCmds = {
inline: true inline: true
}, { }, {
name: "`!` [Optional]", name: "`!` [Optional]",
value: "Exploding, rolls another dy for every crit roll", value: "Exploding, rolls another `dy` for every crit success",
inline: true
}, {
name: "`!o` [Optional]",
value: "Exploding Once, rolls one `dy` for each original crit success",
inline: true
}, {
name: "`!=u` [Optional]",
value: "Explode on `u`, rolls another `dy` for every die that lands on `u`",
inline: true
}, {
name: "`!>u` [Optional]",
value: "Explode on `u` and greater, rolls another `dy` for every die that lands on `u` or greater",
inline: true
}, {
name: "`!<u` [Optional]",
value: "Explode on `u` and under, rolls another `dy` for every die that lands on `u` or less",
inline: true
}, {
name: "`!o=u` [Optional]",
value: "Explodes Once on `u`, rolls another `dy` for each original die that landed on `u`",
inline: true inline: true
} }
] ]
}, { }, {
color: rollHelpColors.details,
fields: [
{
name: "`!o>u` [Optional]",
value: "Explode Once on `u` and greater, rolls another `dy` for each original die that landed on `u` or greater",
inline: true
}, {
name: "`!o<u` [Optional]",
value: "Explode Once on `u` and under, rolls another `dy` for each original die that landed on `u` or less",
inline: true
}
]
}, {
color: rollHelpColors.decorators,
title: "Roll Command Decorators:", title: "Roll Command Decorators:",
description: `This command also has some useful decorators that can used. These decorators simply need to be placed after all rolls in the message.
Examples: \`${config.prefix}d20${config.postfix} -nd\`, \`${config.prefix}d20${config.postfix} -nd -s\`, \`${config.prefix}d20${config.postfix} ${config.prefix}d20${config.postfix} ${config.prefix}d20${config.postfix} -o a\``,
fields: [ fields: [
{ {
name: "Details:", name: "`-nd` - No Details",
value: `This command also has some useful decorators that can used. These decorators simply need to be placed after all rolls in the message. value: "Suppresses all details of the requested roll",
inline: true
}, {
name: "`-snd` - Super No Details",
value: "Suppresses all details of the requested roll and hides no details message",
inline: true
}, {
name: "`-s` - Spoiler",
value: "Spoilers all details of the requested roll",
inline: true
}, {
name: "`-m` - Maximize Roll",
value: "Rolls the theoretical maximum roll, cannot be used with -n",
inline: true
}, {
name: "`-n` - Nominal Roll",
value: "Rolls the theoretical nominal roll, cannot be used with -m",
inline: true
}, {
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",
inline: true
}, {
name: "`-o [direction]` - Order Roll",
value: `Rolls the requested roll and orders the results in the requested direction
Examples: \`${config.prefix}d20${config.postfix} -nd\`, \`${config.prefix}d20${config.postfix} -nd -s\`` Available directions:
}, { \`a\` - Ascending (least to greatest)
name: "`-nd`", \`d\` - Descending (greatest to least)`,
value: "No Details - Suppresses all details of the requested roll",
inline: true
}, {
name: "`-snd`",
value: "Super No Details - Suppresses all details of the requested roll and hides no details message",
inline: true
}, {
name: "`-s`",
value: "Spoiler - Spoilers all details of the requested roll",
inline: true
}, {
name: "`-m`",
value: "Maximize Roll - Rolls the theoretical maximum roll, cannot be used with -n",
inline: true
}, {
name: "`-n`",
value: "Nominal Roll - Rolls the theoretical nominal roll, cannot be used with -m",
inline: true
}, {
name: "`-gm @user1 @user2 @usern`",
value: "GM Roll - 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
}, {
name: "`-o a` or `-o d`",
value: "Order Roll - Rolls the requested roll and orders the results in the requested direction",
inline: true inline: true
} }
] ]
}, { }, {
color: rollHelpColors.results,
title: "Results Formatting:", title: "Results Formatting:",
description: "The results have some formatting applied on them to provide details on what happened during this roll.",
fields: [ fields: [
{ {
name: "Details:",
value: "The results have some formatting applied on them to provide details on what happened during this roll."
}, {
name: "Bold", name: "Bold",
value: "Critical successes will be **bolded**.", value: "Critical successes will be **bolded**.",
inline: true inline: true
@ -381,10 +401,8 @@ export const generatePing = (time: number) => ({
export const generateReport = (msg: string) => ({ export const generateReport = (msg: string) => ({
embeds: [{ embeds: [{
fields: [{ title: "USER REPORT:",
name: "USER REPORT:", description: msg || "No message"
value: msg || "No message"
}]
}] }]
}); });
@ -419,19 +437,15 @@ export const generateStats = (guildCount: number, channelCount: number, memberCo
export const generateApiFailed = (args: string) => ({ export const generateApiFailed = (args: string) => ({
embeds: [{ embeds: [{
fields: [{ title: `Failed to ${args} API rolls for this guild.`,
name: `Failed to ${args} API rolls for this guild.`, description: "If this issue persists, please report this to the developers."
value: "If this issue persists, please report this to the developers."
}]
}] }]
}); });
export const generateApiStatus = (banned: boolean, active: boolean) => ({ export const generateApiStatus = (banned: boolean, active: boolean) => ({
embeds: [{ embeds: [{
fields: [{ title: `The Artificer's API is ${config.api.enable ? "currently enabled" : "currently disabled"}.`,
name: `The Artificer's API is ${config.api.enable ? "currently enabled" : "currently disabled"}.`, description: banned ? "API rolls are banned from being used in this guild.\n\nThis will not be reversed." : `API rolls are ${active ? "allowed" : "blocked from being used"} in this guild.`
value: banned ? "API rolls are banned from being used in this guild.\n\nThis will not be reversed." : `API rolls are ${active ? "allowed" : "blocked from being used"} in this guild.`
}]
}] }]
}); });
@ -443,10 +457,8 @@ export const generateApiSuccess = (args: string) => ({
export const generateDMFailed = (user: string) => ({ export const generateDMFailed = (user: string) => ({
embeds: [{ embeds: [{
fields: [{ title: `WARNING: ${user} could not be messaged.`,
name: `WARNING: ${user} could not be messaged.`, description: "If this issue persists, make sure direct messages are allowed from this server."
value: "If this issue persists, make sure direct messages are allowed from this server."
}]
}] }]
}); });

View File

@ -138,7 +138,7 @@ export const roll = (rollStr: string, maximiseRoll: boolean, nominalRoll: boolea
case "ro": case "ro":
case "ro=": case "ro=":
rollConf.reroll.once = true; rollConf.reroll.once = true;
// falls through as ro/ro= functions the same as r // falls through as ro/ro= functions the same as r/r= in this context
case "r": case "r":
case "r=": case "r=":
// Configure Reroll (this can happen multiple times) // Configure Reroll (this can happen multiple times)
@ -147,7 +147,7 @@ export const roll = (rollStr: string, maximiseRoll: boolean, nominalRoll: boolea
break; break;
case "ro>": case "ro>":
rollConf.reroll.once = true; rollConf.reroll.once = true;
// falls through as ro> functions the same as r // falls through as ro> functions the same as r> in this context
case "r>": case "r>":
// Configure reroll for all numbers greater than or equal to tNum (this could happen multiple times, but why) // Configure reroll for all numbers greater than or equal to tNum (this could happen multiple times, but why)
rollConf.reroll.on = true; rollConf.reroll.on = true;
@ -158,7 +158,7 @@ export const roll = (rollStr: string, maximiseRoll: boolean, nominalRoll: boolea
break; break;
case "ro<": case "ro<":
rollConf.reroll.once = true; rollConf.reroll.once = true;
// falls through as ro< functions the same as r // falls through as ro< functions the same as r< in this context
case "r<": case "r<":
// Configure reroll for all numbers less than or equal to tNum (this could happen multiple times, but why) // Configure reroll for all numbers less than or equal to tNum (this could happen multiple times, but why)
rollConf.reroll.on = true; rollConf.reroll.on = true;
@ -211,10 +211,49 @@ export const roll = (rollStr: string, maximiseRoll: boolean, nominalRoll: boolea
rollConf.critFail.range.push(i); rollConf.critFail.range.push(i);
} }
break; break;
case "!o":
rollConf.exploding.once = true;
// falls through as !o functions the same as ! in this context
case "!": case "!":
// Configure Exploding // Configure Exploding
rollConf.exploding.on = true; rollConf.exploding.on = true;
if (afterNumIdx > 0) {
// User gave a number to explode on, save it
rollConf.exploding.nums.push(tNum);
} else {
// User did not give number, use cs
afterNumIdx = 1; afterNumIdx = 1;
}
break;
case "!o=":
rollConf.exploding.once = true;
// falls through as !o= functions the same as != in this context
case "!=":
// Configure Exploding (this can happen multiple times)
rollConf.exploding.on = true;
rollConf.exploding.nums.push(tNum);
break;
case "!o>":
rollConf.exploding.once = true;
// falls through as !o> functions the same as !> in this context
case "!>":
// Configure Exploding for all numbers greater than or equal to tNum (this could happen multiple times, but why)
rollConf.exploding.on = true;
for (let i = tNum; i <= rollConf.dieSize; i++) {
log(LT.LOG, `Handling roll ${rollStr} | Parsing !> ${i}`);
rollConf.exploding.nums.push(i);
}
break;
case "!o<":
rollConf.exploding.once = true;
// falls through as !o< functions the same as !< in this context
case "!<":
// Configure Exploding for all numbers less than or equal to tNum (this could happen multiple times, but why)
rollConf.exploding.on = true;
for (let i = 1; i <= tNum; i++) {
log(LT.LOG, `Handling roll ${rollStr} | Parsing !< ${i}`);
rollConf.exploding.nums.push(i);
}
break; break;
default: default:
// Throw error immediately if unknown op is encountered // Throw error immediately if unknown op is encountered
@ -342,7 +381,7 @@ export const roll = (rollStr: string, maximiseRoll: boolean, nominalRoll: boolea
// If we need to reroll this roll, flag its been replaced and... // If we need to reroll this roll, flag its been replaced and...
// This big boolean statement first checks if reroll is on, if the roll is within the reroll range, and finally if ro is ON, make sure we haven't already rerolled the roll // This big boolean statement first checks if reroll is on, if the roll is within the reroll range, and finally if ro is ON, make sure we haven't already rerolled the roll
if (rollConf.reroll.on && rollConf.reroll.nums.indexOf(rollSet[i].roll) >= 0 && (!rollConf.reroll.once || rollConf.reroll.once && !rollSet[i ? (i - 1) : i].rerolled)) { if (rollConf.reroll.on && rollConf.reroll.nums.indexOf(rollSet[i].roll) >= 0 && (!rollConf.reroll.once || !rollSet[i ? (i - 1) : i].rerolled)) {
rollSet[i].rerolled = true; rollSet[i].rerolled = true;
// Copy the template to fill out for this iteration // Copy the template to fill out for this iteration
@ -365,7 +404,8 @@ export const roll = (rollStr: string, maximiseRoll: boolean, nominalRoll: boolea
// Slot this new roll in after the current iteration so it can be processed in the next loop // Slot this new roll in after the current iteration so it can be processed in the next loop
rollSet.splice(i + 1, 0, newRoll); rollSet.splice(i + 1, 0, newRoll);
} else if (rollConf.exploding.on && !rollSet[i].rerolled && rollSet[i].critHit) { } else if (rollConf.exploding.on && !rollSet[i].rerolled && (rollConf.exploding.nums.length ? rollConf.exploding.nums.indexOf(rollSet[i].roll) >= 0 : rollSet[i].critHit) && (!rollConf.exploding.once || !rollSet[i].exploding)) {
// If we have exploding.nums set, use those to determine the exploding range, and make sure if !o is on, make sure we don't repeatedly explode
// If it exploded, we keep both, so no flags need to be set // If it exploded, we keep both, so no flags need to be set
// Copy the template to fill out for this iteration // Copy the template to fill out for this iteration