Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GiveawayManager

Hierarchy

  • GiveawayManager

Index

Constructors

constructor

Properties

Readonly client

client: KlasaClient

The Discord Client

readonly

Private giveaways

giveaways: Giveaway[] = []

Array of giveaways to be updated

running

running: Giveaway[] = []

A queue of all running giveaways

Accessors

provider

  • get provider(): Provider

Methods

Private add

create

  • Creates a giveaway in the given channel with the the given giveaway data

    example
    client.giveawayManager.create(msg.channel, {
        endsAt: Date.now() + 1000 * 60 * 60, // 1 hour duration
        author: msg.author.id,
        title: 'FREE NITRO!!',
        winnerCount: 1
    });

    Parameters

    • channel: TextChannel

      TextChannel where the giveaway will run

    • rawData: GiveawayCreateData

      Data for the created giveaway

    Returns Promise<Giveaway>

delete

  • delete(id: string): Promise<null>
  • Deletes a giveaway with the given message id (sent by the bot). This giveaway will no longer be run

    example
    client.giveawayManager.delete('720919015068925974').catch(() => console.log());

    Parameters

    • id: string

      ID of the giveaway to delete

    Returns Promise<null>

edit

end

  • end(id: string): Promise<Message | null>
  • Ends a giveaway with the given message id (sent by the bot). The giveaway gets finished and the winners are listed

    example
    client.giveawayManager.end('720919015068925974').catch(() => console.log());

    Parameters

    • id: string

      ID of the giveaway to end

    Returns Promise<Message | null>

init

  • init(): Promise<void>

Private refresh

  • refresh(): void

reroll

  • Rerolls a finished giveaway with the given message and Reroll Data and returns an array of winners

    example
    const winners = await client.giveawayManager.reroll(msg)
    msg.send(`🎉 **New winner(s) are**: ${winners.map(w => w.toString()).join(', ')}`)

    Parameters

    • msg: KlasaMessage

      Giveaway Message to reroll

    • Optional data: GiveawayRerollData

      Giveaway reroll options

    Returns Promise<GuildMember[]>

Private update

  • update(giveaway: Giveaway): Promise<Message | null>

Generated using TypeDoc