import { Plugin } from '../../common/plugin' ; import { IContainer , IMessage , ChannelType } from '../../common/types' ; import { MessageEmbed } from 'discord.js' ; export default class CoinToss extends Plugin { public commandName : string = 'cointoss' ; public name : string = 'Coin Toss Plugin' ; public description : string = 'Ask Lion to toss a coin or if given arguments, choose among the arguments.' ; public usage : string = 'cointoss\ncointoss <arg_1> <arg_2> <arg_n>' ; public override pluginAlias : string [ ] = [ 'cointoss' , 'coin' ] ; public permission : ChannelType = ChannelType . Public ; private _embed : MessageEmbed = new MessageEmbed ( ) ; private _coinImg : string = 'https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/apple/285/coin_1fa99.png' ; private _wandImg : string = 'https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/apple/285/magic-wand_1fa84.png' ; private _defaultArgs : string [ ] = [ 'Heads' , 'Tails' ] ; constructor ( public container ) { super ( ) ; } public execute ( message , args ) { const responses = [ ] ; if ( args . length === 0 ) { this . _embed . setAuthor ( 'Lion flipped a coin and it lands on...' , this . _coinImg ) ; responses . push ( ... this . _defaultArgs ) ; } else { this . _embed . setAuthor ( 'Lion chooses...' , this . _wandImg ) ; responses . push ( ... args ) ; } const choice = Math . floor ( Math . random ( ) * responses . length ) ; this . _embed . setColor ( '#0099ff' ) . setTitle ( responses [ choice ] ) ; message . reply ( { embeds : [ this . _embed ] } ) ; } }