Skip to main content

tictactoe

One line implementation of a super enjoyable tictactoe game.

Now with AI (one-player) mode ! Just don't mention a opponent and you will play with our ai system. Uses https to call simply-api

Implementation

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

Output

tictactoe

Types

simplydjs.tictactoe(
msgOrInt: ExtendedMessage | ExtendedInteraction,
options: tictactoeOptions = {}
): Promise<User>
  • Resolves: User (The winner of the game)

Options

tictactoeOptions

ParameterTypeRequiredDefaultDescription
strictbooleanfalseEnables strict mode in tictactoe
embedTictactoeEmbedsDefault EmbedsPass an Embeds Object to customize all the embeds
type'Button'/'Embed''Button'Choose the way you want to show the results of the match
maxnumber5Limit the number of games running at a time per guild. For no limit set it to 999
userUsernoneThe opponent you're playing with.
buttonsTictactoeButtonsDefault ButtonsPass an tictactoeButtons Object to customize the buttons
export type tictactoeOptions = {
embed?: TictactoeEmbeds;
user?: User;
type?: 'Button' | 'Embed';
max: number;

buttons?: TictactoeButtons;

strict?: boolean;
};

TictactoeEmbeds

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 TictactoeEmbeds {
request?: CustomizableEmbed;
win?: CustomizableEmbed;
draw?: CustomizableEmbed;
game?: CustomizableEmbed;
timeout?: CustomizableEmbed;
decline?: CustomizableEmbed;
}

tictactoeButtons

ParameterTypeDescription
XCustomizableButtonA CustomizableButton Object to customize the "X" player button
OCustomizableButtonA CustomizableButton Object to customize the "O" player button
blankCustomizableButtonA CustomizableButton Object to customize un-moved place button
export interface TictactoeButtons {
X?: CustomizableButton;
O?: CustomizableButton;
blank?: CustomizableButton;
}

Example

  • Default settings

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

simplydjs.tictactoe(interaction)
  • Customized with options

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

simplydjs.tictactoe(interaction, {
strict: true,
type: 'Embed',
buttons: {
X: { style: ButtonStyle.Danger },
O: { style: ButtonStyle.Success },
blank: { style: ButtonStyle.Secondary }
},
embed: {
game: {
color: simplydjs.toRgb("#406dbc")
}
}
})