Skip to content

Conversation

@sjkd23
Copy link
Collaborator

@sjkd23 sjkd23 commented Sep 11, 2023

Roll command updates:

  • Optional 'number' option for /roll, which allows you to roll for multiple Gachas at once.
    - When rolling multiple times, you can cycle through the Gachas you got using the 'Previous' and 'Next' buttons.
    - Only interaction user can use the buttons

  • 'Roll Again!' button which prompts you to choose a number of rolls
    - User must send a message containing ONLY a number

  • Each roll cost 10 coins/balance.

Database functions updated:

  • Used findOrCreate in a lot of places, instead of making it two seperate 'find' and 'create' functions.
  • Added documentation to new functions.
  • Function names are (hopefully) intuitive.

New Database Schema:

  • Added GACHA_URL_LIST array to the 'Gacha' database, instead of using the array itself in the code.

image

Copy link
Member

@ewang2002 ewang2002 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few changes, but looks good!

@sjkd23 sjkd23 requested a review from ewang2002 September 18, 2023 06:41
* @param {number} max - the highest possible number
* @returns - returns the random number
*/
export async function rng(min: number, max: number): Promise<number> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function does not need to be async

rarity = 'uncommon';
} else if (rndm > 90 && rndm <= 99) {
rarity = 'rare';
} else if (rndm >= 100) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} else if (rndm >= 100) {
} else {

} else if (rndm >= 100) {
rarity = 'legendary';
}
const randomGacha = await getRandomGachaOfRarity(rarity!);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const randomGacha = await getRandomGachaOfRarity(rarity!);
const randomGacha = await getRandomGachaOfRarity(rarity);

if (questionString.length > 256) {
interaction.reply(`Question is too long. (max 256 char.)`);
await interaction.reply(`Question is too long. (max 256 char.)`);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean to return here?


if (i.customId === BUTTONS.ROLL_AGAIN_ID) {
if (rollAgainInUse) {
await i.update({})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try something like deferReply or deferUpdate

Also, be consistent w/ the semicolon usage

if (!isNaN(parsedNumber)) {
msgCollector.stop();
rollAgainInUse = false;
await Roll.run(interaction, parsedNumber);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try not to recursively call the run function. You can do this in some other function, but not here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants