Class Bot<TUser>Abstract

The heart of your bot. Subclass this to get started.

Type Parameters

Constructors

  • Create a bot.

    Type Parameters

    Parameters

    • clientID: string

      Client ID (unused right now)

    • secret: string

      Bot secret

    • client: Client<boolean>

      Base Discord client with intentions set

    Returns Bot<TUser>

Properties

client: Client<boolean>
clientID: string
commands: Command<Bot<TUser>, TUser, Bot<TUser>>[] = []
components: Component<TUser, Bot<TUser>>[] = []
errorPing: Role
hasStarted: boolean = false
log: Logger<ILogObj> = LOG_CONFIG.DEFAULT_LOGGER
logChannel: TextChannel
secret: string

Methods

  • Beta

    Gets a user by its id. This will eventually be renamed to getUser probably.

    Parameters

    • id: string

      User id

    • guild: string = ""

    Returns TUser

  • Runs right before the client logs in.

    Returns void

  • Runs right before the application quits.

    Returns Promise<void>

  • Runs when the bot joins a guild.

    Parameters

    Returns Promise<void>

  • Runs when there is an interaction.

    Parameters

    Returns Promise<void>

  • Runs after the bot logs in.

    Parameters

    Returns Promise<void>

  • Runs when a message is sent.

    Parameters

    Returns Promise<void>

  • Runs when a user joins.

    Parameters

    Returns Promise<void>

  • Refreshes commands for all servers.

    It is recommended to hook this up to a command.

    Returns Promise<void>

    Example

    export default class RefreshCommand<TUser, TBot<TUser>> extends Command<TUser, TBot<TUser>> {
    public getName() { return "refresh"; }

    public create() {
    return new SlashCommandBuilder()
    .setName(this.getName())
    .setDescription("Refresh commands")
    .setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers);
    }

    public async execute(msg: ChatInputCommandInteraction<CacheType>) {
    await msg.deferReply();
    await this.bot.refreshCommands();
    await msg.editReply("Refreshed commands");
    }
    }
  • Start the bot.

    Returns Promise<void>

  • Checks to see if a user is in any of the servers this bot is in.

    Parameters

    • id: string

      User id

    Returns boolean

    If the user is in a server

    Remarks

    It is recommended to only use this if this bot is only in one server.