Options
All
  • Public
  • Public/Protected
  • All
Menu

Queries a specified subreddit for a random image post to post in the chat

Hierarchy

Index

Constructors

constructor

  • Returns Reddit

Properties

Private ResponseUrl

ResponseUrl: string

Stores the URL of a suitable post

Protected aliases

aliases: string = "r"

Protected commandName

commandName: string = "reddit"

Protected desc

desc: string = "gets a random post from a specified subreddit, only returns SFW posts unless the channels is" +"marked NSFW"

Private domains

domains: string[] = ["i.redd.it", "i.imgur.com", "gfycat.com"]

image hosting domains accepted by Reddit to prevent linking to unkown sites

error

error: Error

errorString

errorString: string

Private forbidden

forbidden: string[] = ["watchpeopledie","kotakuinaction","physicalremoval","braincels","redpill","drama","gamerghazi","popping","poop","popping","shit","2booty","gore","guro","shit","cringeanarchy","shittyfoodporn",]

Array of strings of subreddits the bot should not pull from

Protected member

member: GuildMember

Protected message

message: Message

Protected needParamValues

needParamValues: boolean = true

Private nsfw

nsfw: boolean

Whether or not the channel for the command is NSFW

Protected paramValues

paramValues: string[]

Protected params

params: string = "<subreddit name>"

Protected reply

reply: string | object

Protected replyTo

replyTo: boolean = false

Protected server

server: string

warning

warning: Error

Methods

Private checkResponseChildren

  • checkResponseChildren(Response: any): boolean
  • Loops through all children of a query response to find if any of them meet the required critera

    Parameters

    • Response: any

      the array of the children part of the Reddit API response

    Returns boolean

    true if a suitable post is found false otherwise

Private checkSubreddit

  • checkSubreddit(sub: any): Promise<boolean | string>
  • Queries a subreddit's About info to see if it's NSFW and whether it's quarantined or private or not

    Parameters

    • sub: any

      the name of the subreddit

    Returns Promise<boolean | string>

    true if all ok, false if NSFW even thought the channel isn't or a string containing either private or quarantined if either of those are true for the sub

errorRespond

  • errorRespond(): void
  • Wrapper function which sets a generic error message to respond with and calls respond()

    Returns void

exec

  • exec(): Promise<boolean | string>
  • Returns Promise<boolean | string>

Private fetchRed

  • fetchRed(sub: string): Promise<boolean | string>
  • checks the subreddit if it NSFW or not and whether it's quarantined or not queries a random post and returns an appropriate one if able

    Parameters

    • sub: string

      the name of the subreddit to query

    Returns Promise<boolean | string>

Protected getParams

  • getParams(): string[]
  • Gets an an array with all the parameters passed to a command

    Returns string[]

    string[]

Private queryReddit

  • queryReddit(sub: any, limit?: number): Promise<boolean | string>
  • Performs the query to get a post from the subreddit, or empty if a suitable post can't be found

    Parameters

    • sub: any

      the name of the subreddit

    • Default value limit: number = 1

      the index of number of queries performed, can't be more than 5 before the function gives up

    Returns Promise<boolean | string>

respond

  • respond(): void
  • A base function that returns whatever reply has been set by other base functions, the command object returns this response after the command has been successfully ran defaults to sending it as a normal message, but can send it as reply if replyTo is set to true

    Returns void

Private returnNSFW

  • returnNSFW(): boolean
  • checks whether the channel the request was made in was NSFW or not

    Returns boolean

returnProperties

  • returnProperties(): { alias: string | string[]; desc: string; name: string; syntax: string }
  • Returns the commands properties, for use in the Help command

    Returns { alias: string | string[]; desc: string; name: string; syntax: string }

    object

    • alias: string | string[]
    • desc: string
    • name: string
    • syntax: string

run

  • run(message: Message): Promise<{}>
  • The meat of the object, this function is called by the commander object and instantiates the object proper with all required values, then runs the encompassing function and returns the resulting promise object

    Parameters

    • message: Message

    Returns Promise<{}>

Legend

  • Class
  • Constructor
  • Method
  • Variable
  • Function
  • Inherited property
  • Inherited method
  • Private property
  • Private method
  • Interface
  • Protected property

Generated using TypeDoc