Options
All
  • Public
  • Public/Protected
  • All
Menu

Discord-Rose

The simple Discord library for advanced users.

Installation

Run npm i --save discord-rose

Links

Wiki Docs

Support Server

NPM, GitHub

Simple bot

You can easily use the SingleWorker class for easy use of discord-rose, for scaled solution, look below

./index.js

const { SingleWorker } = require('discord-rose')

const worker = new SingleWorker({
  token: 'BOT TOKEN'
})

worker.commands
  .prefix('!')
  .add({
    command: 'hello',
    exec: (ctx) => {
      ctx.reply('World!')
    }
  })

Scaled Bot

You can instead use a Master & Worker solution, one master managing multiple workers/clusters, which hold x amount of shards, making it much more efficient.

./master.js

const { Master } = require('discord-rose')
const path = require('path')

const master = new Master(path.resolve(__dirname, './worker.js'), {
  token: 'BOT TOKEN'
})

master.start()

./worker.js

const { Worker } = require('discord-rose')

const worker = new Worker()

worker.commands
  .prefix('!')
  .add({
    command: 'hello',
    exec: (ctx) => {
      ctx.reply('World!')
    }
  })

Do node ./master.js and you're off to the races. Scaled automatically.

Do note if your bot only ever fits into 1 cluster (< 5000 servers by default), you should consider using SingleWorker since master & worker introduce more process overhead

You can even easily implement slash commands directly within message commands.

Ready to take it to the next level? Take a look out our Wiki

Index

Type aliases

CachedGuild

CachedGuild: Pick<DiscordEventMap["GUILD_CREATE"], Exclude<keyof DiscordEventMap["GUILD_CREATE"], "channels" | "roles" | "members" | "presences">>

Represents a guild cached in Worker#guilds. Does not contain channels, roles, members, or presences.

CommandType

CommandType: string | RegExp

Emoji

Emoji: string | Snowflake

ID of custom emoji or unicode emoji

MessageTypes

MessageTypes: RESTPostAPIChannelMessageJSONBody | RESTPostAPIWebhookWithTokenJSONBody | StringifiedMessageTypes | Embed<any>

Variables

Const PermissionsUtils

PermissionsUtils: { bits: { addReactions: number; administrator: number; auditLog: number; ban: number; connect: number; createInvites: number; createPrivateThreads: number; createPublicThreads: number; deafen: number; embed: number; emojis: number; externalEmojis: number; files: number; kick: number; manageChannels: number; manageGuild: number; manageMessages: number; manageNicknames: number; manageRoles: number; manageThreads: number; mentionEveryone: number; move: number; mute: number; nickname: number; prioritySpeaker: number; readHistory: number; requestToSpeak: number; sendMessages: number; sendMessagesInThreads: number; speak: number; stream: number; tts: number; useApplicationCommands: number; useExternalStickers: number; usePrivateThreads: number; usePublicThreads: number; useSlashCommands: number; useVoiceActivity: number; viewChannel: number; viewInsights: number; webhooks: number }; calculate: any; combine: any; has: any; hasPerms: any } = ...

Type declaration

  • bits: { addReactions: number; administrator: number; auditLog: number; ban: number; connect: number; createInvites: number; createPrivateThreads: number; createPublicThreads: number; deafen: number; embed: number; emojis: number; externalEmojis: number; files: number; kick: number; manageChannels: number; manageGuild: number; manageMessages: number; manageNicknames: number; manageRoles: number; manageThreads: number; mentionEveryone: number; move: number; mute: number; nickname: number; prioritySpeaker: number; readHistory: number; requestToSpeak: number; sendMessages: number; sendMessagesInThreads: number; speak: number; stream: number; tts: number; useApplicationCommands: number; useExternalStickers: number; usePrivateThreads: number; usePublicThreads: number; useSlashCommands: number; useVoiceActivity: number; viewChannel: number; viewInsights: number; webhooks: number }
    • addReactions: number
    • administrator: number
    • auditLog: number
    • ban: number
    • connect: number
    • createInvites: number
    • createPrivateThreads: number
    • createPublicThreads: number
    • deafen: number
    • embed: number
    • emojis: number
    • externalEmojis: number
    • files: number
    • kick: number
    • manageChannels: number
    • manageGuild: number
    • manageMessages: number
    • manageNicknames: number
    • manageRoles: number
    • manageThreads: number
    • mentionEveryone: number
    • move: number
    • mute: number
    • nickname: number
    • prioritySpeaker: number
    • readHistory: number
    • requestToSpeak: number
    • sendMessages: number
    • sendMessagesInThreads: number
    • speak: number
    • stream: number
    • tts: number
    • useApplicationCommands: number
    • useExternalStickers: number
    • usePrivateThreads: number
    • usePublicThreads: number
    • useSlashCommands: number
    • useVoiceActivity: number
    • viewChannel: number
    • viewInsights: number
    • webhooks: number
  • calculate: function
    • calculate(member: APIGuildMember, guild: CachedGuild, roleList: Collection<string, APIRole>, required: "createInvites" | "kick" | "ban" | "administrator" | "manageChannels" | "manageGuild" | "addReactions" | "auditLog" | "prioritySpeaker" | "stream" | "viewChannel" | "sendMessages" | "tts" | "manageMessages" | "embed" | "files" | "readHistory" | "mentionEveryone" | "externalEmojis" | "viewInsights" | "connect" | "speak" | "mute" | "deafen" | "move" | "useVoiceActivity" | "nickname" | "manageNicknames" | "manageRoles" | "webhooks" | "emojis" | "useSlashCommands" | "useApplicationCommands" | "requestToSpeak" | "manageThreads" | "usePublicThreads" | "usePrivateThreads" | "createPublicThreads" | "createPrivateThreads" | "useExternalStickers" | "sendMessagesInThreads"): boolean
    • deprecated

      Parameters

      • member: APIGuildMember
      • guild: CachedGuild
      • roleList: Collection<string, APIRole>
      • required: "createInvites" | "kick" | "ban" | "administrator" | "manageChannels" | "manageGuild" | "addReactions" | "auditLog" | "prioritySpeaker" | "stream" | "viewChannel" | "sendMessages" | "tts" | "manageMessages" | "embed" | "files" | "readHistory" | "mentionEveryone" | "externalEmojis" | "viewInsights" | "connect" | "speak" | "mute" | "deafen" | "move" | "useVoiceActivity" | "nickname" | "manageNicknames" | "manageRoles" | "webhooks" | "emojis" | "useSlashCommands" | "useApplicationCommands" | "requestToSpeak" | "manageThreads" | "usePublicThreads" | "usePrivateThreads" | "createPublicThreads" | "createPrivateThreads" | "useExternalStickers" | "sendMessagesInThreads"

      Returns boolean

  • combine: function
    • combine(data: { guild: CachedGuild; member: APIGuildMember; overwrites?: APIOverwrite[]; roleList?: Collection<string, APIRole> }): number
    • Adds multiple permission sources together

      Parameters

      • data: { guild: CachedGuild; member: APIGuildMember; overwrites?: APIOverwrite[]; roleList?: Collection<string, APIRole> }

        Data filled with possible permission data

        • guild: CachedGuild
        • member: APIGuildMember
        • Optional overwrites?: APIOverwrite[]
        • Optional roleList?: Collection<string, APIRole>

      Returns number

      Full permission bit

  • has: function
    • has(bit: number | bigint, perm: "createInvites" | "kick" | "ban" | "administrator" | "manageChannels" | "manageGuild" | "addReactions" | "auditLog" | "prioritySpeaker" | "stream" | "viewChannel" | "sendMessages" | "tts" | "manageMessages" | "embed" | "files" | "readHistory" | "mentionEveryone" | "externalEmojis" | "viewInsights" | "connect" | "speak" | "mute" | "deafen" | "move" | "useVoiceActivity" | "nickname" | "manageNicknames" | "manageRoles" | "webhooks" | "emojis" | "useSlashCommands" | "useApplicationCommands" | "requestToSpeak" | "manageThreads" | "usePublicThreads" | "usePrivateThreads" | "createPublicThreads" | "createPrivateThreads" | "useExternalStickers" | "sendMessagesInThreads"): boolean
    • Test a permission on a user

      Parameters

      • bit: number | bigint

        Combined permission

      • perm: "createInvites" | "kick" | "ban" | "administrator" | "manageChannels" | "manageGuild" | "addReactions" | "auditLog" | "prioritySpeaker" | "stream" | "viewChannel" | "sendMessages" | "tts" | "manageMessages" | "embed" | "files" | "readHistory" | "mentionEveryone" | "externalEmojis" | "viewInsights" | "connect" | "speak" | "mute" | "deafen" | "move" | "useVoiceActivity" | "nickname" | "manageNicknames" | "manageRoles" | "webhooks" | "emojis" | "useSlashCommands" | "useApplicationCommands" | "requestToSpeak" | "manageThreads" | "usePublicThreads" | "usePrivateThreads" | "createPublicThreads" | "createPrivateThreads" | "useExternalStickers" | "sendMessagesInThreads"

        Permission name to test

      Returns boolean

      Whether or not the user has permissions

  • hasPerms: function
    • hasPerms(perms: number | bigint, bit: number | bigint): boolean
    • Test two bits together

      Parameters

      • perms: number | bigint

        Combined permissions

      • bit: number | bigint

        Number bit ermission to test

      Returns boolean

      Whether or not the user has permissions

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Generated using TypeDoc