import * as discordeno from "https://deno.land/x/discordeno@18.0.1/template/minimal/deps.ts";
import { bgBlue, red, bold } from "https://deno.land/std@0.224.0/fmt/colors.ts";
console.log(bgBlue(red(bold("Hello world!"))));
This module supports NO_COLOR
environmental variable disabling any coloring
if NO_COLOR
is set.
Variables
Maps the <userId, channelId> for dm channels | |
Functions
Adds a reaction to a message. | |
Adds multiple a reaction to a message. | |
Adds a role to a member. | |
Adds a member to a thread. | |
Sets a thread channel to be archived. | |
Bans a user from a guild. | |
Set background color to black. | |
Set background color to blue. | |
Set background color to bright black. | |
Set background color to bright blue. | |
Set background color to bright cyan. | |
Set background color to bright green. | |
Set background color to bright magenta. | |
Set background color to bright red. | |
Set background color to bright white. | |
Set background color to bright yellow. | |
Set background color to cyan. | |
Set background color to green. | |
Set background color to magenta. | |
Set background color to red. | |
Set background color using 24bit rgb.
| |
Set background color using paletted 8bit colors. https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit | |
Set background color to white. | |
Set background color to yellow. | |
Set text color to black. | |
f blue | Set text color to blue. |
f bold | Make the text bold. |
Checks if the bot has these permissions f0r the given channel | |
Checks if the bot has these permissions in the given guild | |
Set text color to bright black. | |
Set text color to bright blue. | |
Set text color to bright cyan. | |
Set text color to bright green. | |
Set text color to bright magenta. | |
Set text color to bright red. | |
Set text color to bright white. | |
Set text color to bright yellow. | |
Calculates the permissions this member has in the given guild | |
This function converts an array of permissions into the bitwise string. | |
Calculates the permissions this member has for the given Channel | |
This function converts a bitwise string to permission strings | |
Handler used to determine max number of shards to use based upon the max concurrency. | |
Checks if a channel overwrite for a user id or a role id has permission in this channel | |
Check the rate limits for a url or a bucket. | |
Cleans up the queues by checking if there is nothing left and removing it. | |
Create a copy of a channel | |
Connects the bot user to a voice or stage channel. | |
Creates an automod rule in a guild. | |
Creates a channel within a guild. | |
Creates an emoji in a guild. | |
Creates a new thread in a forum channel, and sends a message within the created thread. | |
Create a new Gateway Manager. | |
Creates an application command accessible globally; across different guilds and channels. | |
Creates a guild. | |
Creates an application command only accessible in a specific guild. | |
Creates a guild from a template. | |
Create a new sticker for the guild. | |
Creates a template from a guild. | |
Creates an invite to a channel in a guild. | |
Creates the request body and headers that are necessary to send a request. Will handle different types of methods and everything necessary for discord. | |
Creates a role in a guild. | |
Creates a scheduled event in a guild. | |
Create a new Shard manager. This does not manage a specific range of Shard but the provided Shards on create or when an identify is requested. The aim of this is to provide an easy to use manager which can be used by workers or any other kind of separate process. | |
Creates a stage instance associated with a stage channel. | |
Creates a webhook. | |
Cross-posts a message posted in an announcement channel to subscribed channels. | |
f cyan | Set text color to cyan. |
Pause the execution for a given amount of milliseconds. | |
Deletes an automod rule. | |
Deletes a channel from within a guild. | |
Deletes a permission override for a user or role in a channel. | |
Deletes an emoji from a guild. | |
Deletes a follow-up message to an interaction. | |
Deletes an application command registered globally. | |
Deletes a guild. | |
Deletes an application command registered in a guild. | |
Delete a new sticker for the guild. | |
Deletes a template from a guild. | |
Deletes an integration attached to a guild. | |
Deletes an invite to a channel. | |
Deletes a message from a channel. | |
Deletes multiple messages from a channel. | |
Deletes the initial message response to an interaction. | |
Deletes a reaction added by the bot user from a message. | |
Deletes all reactions for all emojis from a message. | |
Deletes all reactions for an emoji from a message. | |
Deletes a role from a guild. | |
Deletes a scheduled event from a guild. | |
Deletes the stage instance associated with a stage channel, if one exists. | |
Deletes a user's reaction from a message. | |
Deletes a webhook. | |
Deletes a webhook message. | |
Deletes a webhook message using the webhook token, thereby bypassing the need for authentication + permissions. | |
f dim | The text emits only a small amount of light. |
Kicks a member from a voice channel | |
Edits the permissions for a guild application command. | |
Edits an automod rule. | |
Edits the nickname of the bot user. | |
Modifies the bot's username or avatar. NOTE: username: if changed may cause the bot's discriminator to be randomized. | |
Edits a channel's settings. | |
Edits the permission overrides for a user or role in a channel. | |
Edits the positions of a set of channels in a guild. | |
Edits an emoji. | |
Edits a follow-up message to an interaction. | |
Edits a global application command. | |
Edits a guild's settings. | |
Edits an application command registered in a guild. | |
Modify a guild's MFA level. Requires guild ownership. | |
Edit the given sticker. | |
Edits a template's settings. | |
Edits a member's properties. | |
Edits a message. | |
Edits the initial message response to an interaction. | |
Edits the original webhook message. | |
Edits the voice state of the bot user. | |
Edits a role in a guild. | |
Edits a scheduled event. | |
Edits a stage instance. | |
Update a thread's settings. Requires the | |
Edits the voice state of another user. | |
Edits a webhook. | |
Edits a webhook message. | |
Edits a webhook using the webhook token, thereby bypassing the need for authentication + permissions. | |
Edits a guild's welcome screen. | |
Edits the settings of a guild's widget. | |
Enables sweepers for your bot but will require, enabling cache first. | |
Pass in a (compatible) bot instance, and get sweet file loader goodness. Remember to capture the output of this function! | |
CREDIT: https://gist.github.com/enepomnyaschih/72c423f727d395eeaa09697058238727 Encodes a given Uint8Array, ArrayBuffer or string into RFC4648 base64 representation | |
Executes a webhook, causing a message to be posted in the channel configured for the webhook. | |
This function will import the specified directories | |
Fetch members for an entire guild then return the entire guilds cached members. | |
Fetches the list of members for a guild over the gateway. | |
Writes, then imports all everything in fileloader.ts | |
Follows an announcement channel, allowing messages posted within it to be cross-posted into the target channel. | |
Help format an image url. | |
Gets the list of all active threads for a guild. | |
Gets the permissions of a guild application command. | |
Gets the permissions of all application commands registered in a guild by the ID of the guild. | |
Get the applications info | |
Gets a guild's audit log. | |
Gets an automod rule by its ID. | |
Gets the list of automod rules for a guild. | |
Gets the list of available voice regions. | |
Builds a URL to a user's avatar stored in the Discord CDN. | |
Gets a ban by user ID. | |
Gets the list of bans for a guild. | |
Get the bot id from the bot token. WARNING: Discord staff has mentioned this may not be stable forever. Use at your own risk. However, note for over 5 years this has never broken. | |
Gets a channel by its ID. | |
Gets the list of invites for a channel. | |
Gets the list of channels for a guild. | |
Gets a list of webhooks for a channel. | |
Get whether text color change is enabled or disabled. | |
Gets or creates a DM channel with a user. | |
Gets an emoji by its ID. | |
Gets the list of emojis for a guild. | |
Builds a URL to an emoji in the Discord CDN. | |
Gets a follow-up message to an interaction by the ID of the message. | |
Get the bots Gateway metadata that can help during the operation of large or sharded bots. | |
Gets a global application command by its ID. | |
Gets the list of your bot's global application commands. | |
Gets a guild by its ID. | |
Gets a guild application command by its ID. | |
Gets the list of application commands registered by your bot in a guild. | |
Builds a URL to the guild banner stored in the Discord CDN. | |
Builds a URL to the guild icon stored in the Discord CDN. | |
Gets the preview of a guild by a guild's ID. | |
Builds the URL to a guild splash stored in the Discord CDN. | |
Returns a sticker object for the given guild and sticker IDs. | |
Returns an array of sticker objects for the given guild. | |
Gets a template by its code. | |
Gets the list of templates for a guild. | |
Gets the list of webhooks for a guild. | |
Gets the list of integrations attached to a guild. | |
Gets an invite to a channel by its invite code. | |
Gets the list of invites for a guild. | |
Gets the member object by user ID. | |
Gets the list of members for a guild. | |
Highly recommended to NOT use this function to get members instead use fetchMembers(). REST(this function): 50/s global(across all shards) rate limit with ALL requests this included GW(fetchMembers): 120/m(PER shard) rate limit. Meaning if you have 8 shards your limit is 960/m. | |
Gets a message from a channel by the ID of the message. | |
Gets multiple messages from a channel. | |
Get the missing Channel permissions this member has | |
Get the missing Guild permissions this member has | |
Returns the list of sticker packs available to Nitro subscribers. | |
Gets the initial message response to an interaction. | |
Gets the pinned messages for a channel. | |
Gets the list of private archived threads for a channel. | |
Gets the list of private archived threads the bot is a member of for a channel. | |
Gets the number of members that would be kicked from a guild during pruning. | |
Gets the list of public archived threads for a channel. | |
Gets the list of users that reacted with an emoji to a message. | |
Gets the list of roles for a guild. | |
Gets a scheduled event by its ID. | |
Gets the list of scheduled events for a guild. | |
Gets the list of subscribers to a scheduled event from a guild. | |
Gets the stage instance associated with a stage channel, if one exists. | |
Returns a sticker object for the given sticker ID. | |
Gets a thread member by their user ID. | |
Gets the list of thread members for a thread. | |
This function will return the raw user payload in the rare cases you need to fetch a user directly from the API. | |
Gets information about the vanity url of a guild. | |
Gets the list of voice regions for a guild. | |
Gets a webhook by its ID. | |
Gets a webhook message by its ID. | |
Gets a webhook using the webhook token, thereby bypassing the need for authentication + permissions. | |
Gets the welcome screen for a guild. | |
Gets the guild widget by guild ID. | |
Builds a URL to the guild widget image stored in the Discord CDN. | |
Gets the settings of a guild's widget. | |
f gray | Set text color to gray. |
Set text color to green. | |
Checks if the given member has these permissions for the given channel | |
Checks if the given member has these permissions in the given guild | |
TS save way to check if a property exists in an object | |
Make the text hidden. | |
Checks if the first role is higher than the second role | |
Gets the highest role from the member in this guild | |
Recursively generates an array of unique paths to import using | |
Invert background color and text color. | |
Checks if the member has a higher position than the given role | |
Make the text italic. | |
Adds the bot user to a thread. | |
Kicks a member from a guild. | |
Leaves a guild. | |
Removes the bot user from a thread. | |
Leaves the voice channel the bot user is currently in. | |
Sets a thread channel to be locked. | |
Set text color to magenta. | |
Returns the permissions that are not in the given permissionBits | |
Edits the positions of a set of roles. | |
Move a member from a voice channel to another. | |
Pins a message in a channel. | |
Processes the queue by looping over each path separately until the queues are empty. | |
This will create a infinite loop running in 1 seconds using tail recursion to keep rate limits clean. When a rate limit resets, this will remove it so the queue can proceed. | |
Processes a request and assigns it to a queue or creates a queue if none exists for it. | |
Processes the rate limit headers and determines if it needs to be rate limited and returns the bucket id if available | |
Initiates the process of pruning inactive members. | |
f red | Set text color to red. |
Removes a role from a member. | |
Removes a member from a thread. | |
Removes the Bot before the token. | |
Throws an error if the bot has not all of the given channel permissions | |
Throws an error if the bot does not have all permissions | |
Throws an error if this member has not all of the given permissions | |
Throws an error if this member has not all of the given permissions | |
Internal function to check if the bot has the permissions to set these overwrites | |
Reset the text modified | |
Set text color using 24bit rgb.
| |
f rgb8 | Set text color using paletted 8bit colors. https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit |
Gets the list of members whose usernames or nicknames start with a provided string. | |
f send | |
Sends a direct message to a user. This can take two API calls. The first call is to create a dm channel. Then sending the message to that channel. Channel ids are cached as needed to prevent duplicate requests. | |
Sends a follow-up message to an interaction. | |
Sends a response to an interaction. | |
Sends a message to a channel. | |
sendInteractionResponse with ephemeral reply | |
Sends a text message. | |
Set changing text color to enabled or disabled | |
Split a url to separate rate limit buckets based on major/minor parameters. | |
Begin spawning shards. | |
Creates a thread, using an existing message as its point of origin. | |
Creates a thread without using a message as the thread's point of origin. | |
f stop | |
Put horizontal line through the center of the text. | |
Remove ANSI escape codes from the string. | |
Suppress all the embeds in this message | |
Synchronises a template with the current state of a guild. | |
Allows users to hook in and change to communicate to different workers across different servers or anything they like. For example using redis pubsub to talk to other servers. | |
Triggers a typing indicator for the bot user. | |
Sets a thread channel to be unarchived. | |
Unbans a user from a guild. | |
Make the text underline. | |
Sets a thread channel to be unlocked. | |
Unpins a pinned message in a channel. | |
Re-registers the list of global application commands, overwriting the previous commands completely. | |
Re-registers the list of application commands registered in a guild, overwriting the previous commands completely. | |
Converts a url to base 64. Useful for example, uploading/creating server emojis. | |
Validates the length of a string in JS. Certain characters in JS can have multiple numbers in length in unicode and discords api is in python which treats length differently. | |
Checks if the given permission bits are matching the given permissions. | |
Set text color to white. | |
Set text color to yellow. |
Interfaces
I Bot | |
Extend the Bot with the Plugin's added functions | |
A Leaky Bucket.
Useful for rate limiting purposes.
This uses | |
I Role | |
I Team | |
I User | |
Type Aliases
Allows any type but T it is recursive | |
Array with no utilty methods, aka Object.create(null) | |
T Ban | |
T Id | object identity type |
https://discord.com/developers/docs/reference#image-formatting json is only for stickers | |
alternative to 'object' or '{}' | |
Makes all of properties in T optional when they're null | undefined it is recursive | |
Non object primitives | |
This is a Shard manager. This does not manage a specific range of Shard but the provided Shards on create or when an identify is requested. The aim of this is to provide an easy to use manager which can be used by workers or any other kind of separate process. | |