// Types for Roar.js (roar.js), so editors can autocomplete. The guide: https://bots.roarnode.com export const VERSION: string; export const DEFAULT_RELAY: string; export function timestampOf(id: string): Date; export function mention(userOrId: User | Member | string): string; export function channelMention(channelOrId: Channel | string): string; export function roleMention(roleOrId: Role | string): string; export class RoarError extends Error { status: number; /** Roar's error code, e.g. 50013 Missing Permissions. */ code: number; body: unknown; } export type ActivityType = "playing" | "streaming" | "listening" | "watching" | "competing"; export interface Presence { status?: "online" | "idle" | "dnd" | "invisible"; activity?: string; activityType?: ActivityType; customStatus?: string; customEmoji?: string; } export interface BotOptions { /** The bot's token (Settings → Developer). Defaults to the ROAR_TOKEN environment variable. */ token?: string; /** Left out: the official node. Or a node id (10 letters, through the relay), or a URL such as https://chat.example.com. Defaults to ROAR_NODE. */ node?: string; /** The relay that finds nodes by id. Default https://roarnode.com. */ relay?: string; presence?: Presence; /** Also hand the bot's own messages to "message" handlers. Default false. */ ownMessages?: boolean; } export interface Embed { title?: string; description?: string; url?: string; /** A number, or a colour like "#5fd96a". */ color?: number | string; author?: string | { name: string; url?: string }; fields?: { name: string; value: string; inline?: boolean }[]; image?: string | { url: string }; thumbnail?: string | { url: string }; footer?: string | { text: string }; timestamp?: Date | string; } export interface FileToSend { name: string; data?: Uint8Array | ArrayBuffer | Blob | string; /** A file on disk instead of `data` (Node, Deno and Bun). */ path?: string; contentType?: string; } export interface MessageOptions { content?: string; embed?: Embed; embeds?: Embed[]; /** Files to attach: paths on disk, or `{ name, data }`. */ files?: (string | FileToSend)[]; /** Don't notify anyone (like @silent). */ silent?: boolean; replyTo?: Message | string; /** With replyTo: false stops the reply pinging the author. */ ping?: boolean; } export type Sendable = string | MessageOptions; export interface ReplyOptions { content?: string; embed?: Embed; embeds?: Embed[]; /** Only the person who used the command sees the answer. */ ephemeral?: boolean; silent?: boolean; } export interface Attachment { id: string; name: string; size: number; contentType: string; width: number | null; height: number | null; /** A full address you can download. */ url: string; } export class User { readonly bot: Bot; id: string; username: string; displayName: string; avatar: string | null; isBot: boolean; isWebhook: boolean; badges: string[]; raw: any; readonly mention: string; readonly createdAt: Date; readonly avatarUrl: string | null; send(content: Sendable): Promise; } export class Member { readonly bot: Bot; readonly guild: Guild; id: string; user: User; nick: string | null; /** Role ids. */ roles: string[]; joinedAt: Date | null; timedOutUntil: Date | null; raw: any; readonly displayName: string; readonly mention: string; hasRole(roleOrName: Role | string): boolean; addRole(roleOrName: Role | string, reason?: string): Promise; removeRole(roleOrName: Role | string, reason?: string): Promise; kick(reason?: string): Promise; ban(reason?: string): Promise; timeout(minutes: number, reason?: string): Promise; send(content: Sendable): Promise; } export class Channel { readonly bot: Bot; id: string; name: string | null; type: "text" | "dm" | "voice" | "group" | "category" | "announcement" | "thread" | "stage" | "forum" | "other"; typeId: number; guildId: string | null; parentId: string | null; topic: string | null; raw: any; readonly guild: Guild | null; readonly mention: string; send(content: Sendable): Promise; typing(): Promise; messages(options?: { limit?: number; before?: string; after?: string }): Promise; fetchMessage(id: string): Promise; createWebhook(name: string): Promise; } export class Role { readonly guild: Guild; id: string; name: string; color: number; permissions: string; raw: any; readonly mention: string; } export class Guild { readonly bot: Bot; id: string; name: string; icon: string | null; ownerId: string | null; systemChannelId: string | null; memberCount: number; channels: Map; roles: Map; members: Map; raw: any; readonly systemChannel: Channel | null; channel(nameOrId: string): Channel | null; role(nameOrId: string): Role | null; member(userOrId: User | string): Member | null; fetchMember(userOrId: User | string): Promise; addRole(userOrId: User | Member | string, roleOrName: Role | string, reason?: string): Promise; removeRole(userOrId: User | Member | string, roleOrName: Role | string, reason?: string): Promise; kick(userOrId: User | Member | string, reason?: string): Promise; ban(userOrId: User | Member | string, reason?: string): Promise; unban(userOrId: User | string, reason?: string): Promise; timeout(userOrId: User | Member | string, minutes: number, reason?: string): Promise; leave(): Promise; } export class Message { readonly bot: Bot; id: string; channelId: string; guildId: string | null; author: User; content: string; type: number; flags: number; pinned: boolean; createdAt: Date; editedAt: Date | null; /** Ids of the users it pings. */ mentions: string[]; mentionsEveryone: boolean; embeds: any[]; attachments: Attachment[]; reactions: { emoji: string; count: number; me: boolean }[]; replyTo: string | null; isWebhook: boolean; raw: any; readonly channel: Channel | null; readonly guild: Guild | null; readonly member: Member | null; readonly mentionsMe: boolean; readonly isDM: boolean; reply(content: Sendable): Promise; react(emoji: string): Promise; unreact(emoji: string): Promise; edit(content: string | { content: string }): Promise; delete(): Promise; pin(): Promise; unpin(): Promise; } export class Interaction { readonly bot: Bot; id: string; token: string; commandName: string; commandId: string; guildId: string | null; channelId: string; user: User; member: Member | null; /** What people filled in, by option name. Users, channels and roles come as ids. */ options: Record; replied: boolean; deferred: boolean; raw: any; readonly guild: Guild | null; readonly channel: Channel | null; optionUser(name: string): User | null; optionChannel(name: string): Channel | null; optionRole(name: string): Role | null; reply(content: string | ReplyOptions): Promise; defer(options?: { ephemeral?: boolean }): Promise; editReply(content: string | ReplyOptions): Promise; } export class Webhook { constructor(url: string); url: string; send(content: string | { content?: string; embed?: Embed; embeds?: Embed[]; username?: string; avatarUrl?: string }): Promise; } export type OptionType = "string" | "integer" | "boolean" | "user" | "channel" | "role" | "number"; export interface CommandOption { name: string; description?: string; type?: OptionType; required?: boolean; choices?: (string | number | { name: string; value: string | number })[]; } export interface CommandDefinition { name: string; description: string; options?: CommandOption[]; } export interface Reaction { userId: string; channelId: string; messageId: string; guildId: string | null; /** "👋", or "name:id" for a server emoji. */ emoji: string; /** A Roar (super) reaction. */ roar: boolean; user: User | null; guild: Guild | null; member: Member | null; fetchMessage(): Promise | undefined; } export interface BotEvents { ready: [bot: Bot]; message: [message: Message]; messageUpdate: [message: Message]; messageDelete: [deleted: { id: string; channelId: string; guildId: string | null }]; reactionAdd: [reaction: Reaction]; reactionRemove: [reaction: Reaction]; memberJoin: [member: Member]; memberUpdate: [member: Member]; memberLeave: [member: Member | { id: string; user: User; guild: Guild }]; guildJoin: [guild: Guild]; guildUpdate: [guild: Guild]; guildLeave: [guild: Guild | { id: string }]; command: [interaction: Interaction]; typing: [typing: { userId: string; channelId: string; guildId: string | null }]; presence: [presence: any]; raw: [type: string, data: any]; error: [error: Error]; disconnect: [info: { code: number; reason: string }]; reconnecting: [info: { delay: number }]; debug: [text: string]; } export class Bot { constructor(options?: BotOptions | string); token: string; node: string; relay: string; user: User | null; applicationId: string | null; guilds: Map; channels: Map; users: Map; commands: Map unknown }>; rest: { get(path: string, query?: Record): Promise; post(path: string, body?: unknown, query?: Record): Promise; put(path: string, body?: unknown): Promise; patch(path: string, body?: unknown): Promise; delete(path: string, body?: unknown): Promise; request(method: string, path: string, options?: { body?: unknown; query?: Record; raw?: BodyInit; contentType?: string; reason?: string; auth?: boolean }): Promise; }; on(event: E, handler: (...args: BotEvents[E]) => unknown): this; once(event: E, handler: (...args: BotEvents[E]) => unknown): this; off(event: E, handler: (...args: BotEvents[E]) => unknown): this; start(): Promise; stop(): void; command(name: string, description: string, handler: (i: Interaction) => unknown): this; command(definition: CommandDefinition, handler: (i: Interaction) => unknown): this; registerCommands(): Promise; send(channelOrId: Channel | string, content: Sendable): Promise; dm(userOrId: User | Member | string, content: Sendable): Promise; setPresence(presence: Presence): void; setActivity(text: string, type?: ActivityType): void; channel(id: string): Channel | null; guild(nameOrId: string): Guild | null; fetchUser(id: string): Promise; } export default Bot;