Skip to main content

rps

A classic RPS game, except this time it's on Discord to play with your pals, how cool is that ?

Implementation

simplydjs.rps(interaction, { 
// options (optional)
})

Output

rps

rps win

Types

simplydjs.rps(
msgOrint: ExtendedMessage | ExtendedInteraction,
options: rpsOptions
): Promise<User>

Options

rpsOptions

ParameterTypeRequiredDefaultDescription
strictbooleanfalseEnables strict mode in rps
embedRpsEmbedsDefault EmbedPass an Embeds Object to customize the embed
buttonsRpsButtonsDefault ButtonsPass a rpsButtons Object to customize the buttons
opponentUsernoneThe opponent you're playing with.
export type rpsOptions = {
embed?: RpsEmbeds;
buttons?: RpsButtons;
opponent?: User;

strict?: boolean;
};

RpsEmbeds

ParameterTypeDescription
requestCustomizableEmbedA CustomizableEmbed Object to customize the game request embed
winCustomizableEmbedA CustomizableEmbed Object to customize the result (winner) embed
drawCustomizableEmbedA CustomizableEmbed Object to customize the draw embed
gameCustomizableEmbedA CustomizableEmbed Object to customize the in-game embed
timeoutCustomizableEmbedA CustomizableEmbed Object to customize the game timeout embed
declineCustomizableEmbedA CustomizableEmbed Object to customize the declined embed
export interface RpsEmbeds {
request?: CustomizableEmbed;
win?: CustomizableEmbed;
draw?: CustomizableEmbed;
game?: CustomizableEmbed;
timeout?: CustomizableEmbed;
decline?: CustomizableEmbed;
}

RpsButtons

ParameterTypeDescription
rockCustomizableButtonA CustomizableButton Object to customize the rock button
paperCustomizableButtonA CustomizableButton Object to customize the paper button
scissorCustomizableButtonA CustomizableButton Object to customize scissor button
export interface RpsButtons {
rock?: CustomizableButton;
paper?: CustomizableButton;
scissor?: CustomizableButton;
}

Example

  • Default settings

rps.js
const simplydjs = require('simply-djs')

simplydjs.rps(interaction)
  • Customized with options

rps.js
const { ButtonStyle } = require('discord.js')
const simplydjs = require('simply-djs')

simplydjs.rps(interaction, {
strict: true,
buttons: {
rock: { style: ButtonStyle.Primary },
paper: { style: ButtonStyle.Success },
scissor: { style: ButtonStyle.Danger }
},
embed: {
game: {
color: simplydjs.toRgb("#406dbc")
}
}
})