import * as discordeno from "https://deno.land/x/discordeno@13.0.0-rc45/template/beginner/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.
Functions
Add a discovery subcategory to the guild. Requires the | |
Create a reaction for the message. Reaction takes the form of name:id for custom guild emoji, or Unicode characters. Requires READ_MESSAGE_HISTORY and ADD_REACTIONS | |
Adds multiple reactions to a message. If | |
Add a role to the member | |
Adds a user to a thread. Requires the ability to send messages in the thread. Requires the thread is not archived. | |
Sets a thread channel to be archived. | |
The users custom avatar or the default avatar if you don't have a member object. | |
Ban a user from the guild and optionally delete previous messages sent by the user. Requires the BAN_MEMBERS permission. | |
Batch edits permissions for all commands in a guild. Takes an array of partial GuildApplicationCommandPermissions objects including | |
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 | |
Handler used to determine max number of shards to use based upon the max concurrency. | |
This function converts a bitwise string to permission strings | |
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 | |
Use this function to close a ws connection properly | |
Connect or join a voice channel inside a guild. By default, the "selfDeaf" option is true. Requires | |
There are two kinds of Application Commands: global commands and guild commands. Global commands are available for every guild that adds your app; guild commands are specific to the guild you specify when making them. Command names are unique per application within each scope (global and guild). That means: | |
Create a channel in your server. Bot needs MANAGE_CHANNEL permissions in the server. | |
Create an emoji in the server. Emojis and animated emojis have a maximum file size of 256kb. Attempting to upload an emoji larger than this limit will fail and return 400 Bad Request and an error message, but not a JSON status code. If a URL is provided to the image parameter, Discordeno will automatically convert it to a base64 string internally. | |
Create a new Gateway Manager. | |
Create a new guild. Returns a guild object on success. Fires a Guild Create Gateway event. This endpoint can be used only by bots in less than 10 guilds. | |
Create a new guild based on a template NOTE: This endpoint can be used only by bots in less than 10 guilds. | |
Creates a template for the guild. Requires the | |
Creates a new invite for this channel. Requires CREATE_INSTANT_INVITE | |
Creates the request body and headers that are necessary to send a request. Will handle different types of methods and everything necessary for discord. | |
Create a new role for the guild. Requires the MANAGE_ROLES permission. | |
Create a guild scheduled event in the guild. A guild can have a maximum of 100 events with | |
Creates a new Stage instance associated to a Stage channel. Requires the user to be a moderator of the Stage channel. | |
Create a new webhook. Requires the MANAGE_WEBHOOKS permission. Returns a webhook object on success. Webhook names follow our naming restrictions that can be found in our Usernames and Nicknames documentation, with the following additional stipulations: | |
f cyan | Set text color to cyan. |
Pause the execution for a given amount of milliseconds. | |
Deletes a application command. | |
Delete a channel in your server. Bot needs MANAGE_CHANNEL permissions in the server. Bot needs MANAGE_THREADS permissions in the server if deleting thread. | |
Delete the channel permission overwrites for a user or role in this channel. Requires | |
Delete the given emoji. Requires the MANAGE_EMOJIS permission. Returns 204 No Content on success. | |
Deletes a followup message for an Interaction. Functions the same as delete webhook message, however this uses your interaction token instead of bot token. Does not support ephemeral followups. | |
Delete a guild permanently. User must be owner. Returns 204 No Content on success. Fires a Guild Delete Gateway event. | |
Deletes a template from a guild.
Requires the | |
Delete the attached integration object for the guild with this id. Requires MANAGE_GUILD permission. | |
To delete your response to a application command. If a message id is not provided, it will default to deleting the original response. | |
Deletes an invite for the given code. Requires | |
Delete a message with the channel id and message id only. | |
Delete messages from the channel. 2-100. Requires the MANAGE_MESSAGES permission | |
Delete a guild role. Requires the MANAGE_ROLES permission. | |
Delete a scheduled event. | |
Deletes the Stage instance. Requires the user to be a moderator of the Stage channel. | |
Delete a webhook permanently. Requires the | |
Delete a webhook permanently. Returns a undefined on success | |
f dim | The text emits only a small amount of light. |
Kicks a member from a voice channel | |
Edits command permissions for a specific command for your application in a guild. | |
Edit the nickname of the bot in this guild | |
Modifies the bot's username or avatar. NOTE: username: if changed may cause the bot's discriminator to be randomized. | |
Update a channel's settings. Requires the | |
Edit the channel permission overwrites for a user or role in this channel. Requires | |
Modify the discovery metadata for the guild. Requires the MANAGE_GUILD permission. Returns the updated discovery metadata object on success. | |
Modify the given emoji. Requires the MANAGE_EMOJIS permission. | |
Edits a followup message for an Interaction. Functions the same as edit webhook message, however this uses your interaction token instead of bot token. Does not support ephemeral followups. | |
Modify a guilds settings. Requires the MANAGE_GUILD permission. | |
Edit a template's metadata.
Requires the | |
To edit your response to a application command. If a messageId is not provided it will default to editing the original response. | |
Edit the member | |
Edit the message. | |
Edit a guild role. Requires the MANAGE_ROLES permission. | |
Modify a guild scheduled event. To start or end an event, use this endpoint to modify the event's status. | |
Update a thread's settings. Requires the | |
Edit a webhook. Requires the | |
Edit a webhook. Returns the updated webhook object on success. | |
Modify a guild widget object for the guild. Requires the MANAGE_GUILD permission. | |
Creates a url to the emoji from the Discord CDN. | |
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! | |
This function will import the specified directories | |
Highly recommended to use this function to fetch members instead of getMember from REST. REST: 50/s global(across all shards) rate limit with ALL requests this included GW(this function): 120/m(PER shard) rate limit. Meaning if you have 8 shards your limit is now 960/m. | |
Writes, then imports all everything in fileloader.ts | |
Follow a News Channel to send messages to a target channel. Requires the | |
Help format an image url. | |
Returns all active threads in the guild, including public and private threads. Threads are ordered by their | |
Fetches the global command for the given Id. If a guildId is provided, the guild command will be fetched. | |
Fetches command permissions for a specific command for your application in a guild. Returns a GuildApplicationCommandPermissions object. | |
Fetches command permissions for all commands for your application in a guild. Returns an array of GuildApplicationCommandPermissions objects. | |
Fetch all the commands for your application. If a guild id is not provided, it will fetch global commands. | |
Get the applications info | |
Get the archived threads for this channel, defaults to public | |
Returns the audit logs for the guild. Requires VIEW AUDIT LOGS permission | |
Returns an array of voice regions that can be used when creating servers. | |
Returns a ban object for the given user or a 404 not found if the ban cannot be found. Requires the BAN_MEMBERS permission. | |
Returns a list of ban objects for the users banned from this guild. Requires the BAN_MEMBERS permission. | |
Fetches a single channel object from the api. | |
Gets the invites for this channel. Requires MANAGE_CHANNEL | |
Returns a list of guild channel objects. | |
Gets the webhooks for this channel. Requires MANAGE_WEBHOOKS | |
Get whether text color change is enabled or disabled. | |
Returns the discovery metadata object for the guild. Requires the | |
Returns a Collection (mapped by Id of the discovery category object) of discovery category objects that can be used when editing guilds | |
Get a user's dm channel. This is required in order to send a DM. | |
Returns an emoji for the given guild and emoji Id. | |
Returns a list of emojis for the given guild. | |
Returns a followup message for an Interaction. Functions the same as get webhook message, however this uses your interaction token instead of bot token. Does not support ephemeral followups. | |
Get the bots Gateway metadata that can help during the operation of large or sharded bots. | |
This function fetches a guild's data. This is not the same data as a GUILD_CREATE. So it does not cache the guild, you must do it manually. | |
Returns the guild preview object for the given id. If the bot is not in the guild, then the guild must be Discoverable. | |
Returns an array of templates. Requires the | |
Returns a list of integrations for the guild. Requires the MANAGE_GUILD permission. | |
Returns an invite for the given code or throws an error if the invite doesn't exists. | |
Get all the invites for this guild. Requires MANAGE_GUILD permission | |
Returns a guild member object for the specified user. | |
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. | |
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. | |
Fetch a single message from the server. Requires VIEW_CHANNEL and READ_MESSAGE_HISTORY | |
Fetches between 2-100 messages. Requires VIEW_CHANNEL and READ_MESSAGE_HISTORY | |
Get the missing Channel permissions this member has | |
Get the missing Guild permissions this member has | |
Returns the initial Interaction response. Functions the same as Get Webhook Message | |
Get pinned messages in this channel. | |
Check how many members would be removed from the server in a prune operation. Requires the KICK_MEMBERS permission | |
Get a list of users that reacted with this emoji. | |
Returns a list of role objects for the guild. | |
Get a guild scheduled event. | |
Get a list of guild scheduled event for the given guild. | |
Gets the stage instance associated with the Stage channel, if it exists. | |
Returns the guild template if it exists | |
Returns thread members objects that are members of the thread. | |
Returns thread members objects that are members of the thread. | |
This function will return the raw user payload in the rare cases you need to fetch a user directly from the API. | |
Returns the code and uses of the vanity url for this server if it is enabled else | |
Returns a list of voice region objects for the guild. Unlike the similar /voice route, this returns VIP servers when the guild is VIP-enabled. | |
Returns the new webhook object for the given id. | |
Returns a previously-sent webhook message from the same token. Returns a message object on success. | |
Returns a list of guild webhooks objects. Requires the MANAGE_WEBHOOKs permission. | |
Returns the new webhook object for the given id, this call does not require authentication and returns no user in the webhook object. | |
Returns the Welcome Screen object for the guild. Requires the | |
Returns the widget for the guild. | |
Returns the widget image URL for the guild. | |
Returns the guild widget object. Requires the MANAGE_GUILD permission. | |
f gray | Set text color to gray. |
Set text color to green. | |
The full URL of the banner from Discords CDN. Undefined if no banner is set. | |
The full URL of the icon from Discords CDN. Undefined when no icon is set. | |
The full URL of the splash from Discords CDN. Undefined if no splash is set. | |
Handler for handling every message event from websocket. | |
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 to the thread. Cannot join an archived thread. | |
Kick a member from the server | |
Leave a guild | |
Removes the bot from a thread. Requires the thread is not archived. | |
Sets a thread channel to be locked. | |
Set text color to magenta. | |
Handler that by default will save the new shard id for each guild this becomes ready in new gateway. This can be overriden to save the shard ids in a redis cache layer or whatever you prefer. These ids will be used later to update all guilds. | |
Returns the permissions that are not in the given permissionBits | |
Modify the positions of a set of role objects for the guild. Requires the MANAGE_ROLES permission. Returns a list of all of the guild's role objects on success. Fires multiple Guild Role Update Gateway events. | |
Move a member from a voice channel to another. | |
Returns the list of sticker packs available to Nitro subscribers. | |
Pin a message in a channel. Requires MANAGE_MESSAGES. Max pins allowed in a channel = 50. | |
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 ratelimited and returns the bucket id if available | |
Begin a prune operation. Requires the KICK_MEMBERS permission. Returns an object with one 'pruned' key indicating the number of members that were removed in the prune operation. For large guilds it's recommended to set the computePruneCount option to false, forcing 'pruned' to null. Fires multiple Guild Member Remove Gateway events. | |
Crosspost a message in a News Channel to following channels. | |
f red | Set text color to red. |
Removes all reactions for all emojis on this message. | |
Removes a discovery subcategory from the guild. Requires the MANAGE_GUILD permission. Returns a 204 No Content on success. | |
Removes a reaction from the given user on this message, defaults to bot. Reaction takes the form of name:id for custom guild emoji, or Unicode characters. | |
Remove a role from the member | |
Removes a user from a thread. Requires the MANAGE_THREADS permission or that you are the creator of the thread. Also requires the thread is not archived. | |
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 | |
The handler to automatically reshard when necessary. | |
Handler that by default closes all shards in the old gateway. Can be overriden if you have multiple servers and you want to communicate through redis pubsub or whatever you prefer. | |
Handler that by default will check all new shards are online in the new gateway. The handler can be overriden if you have multiple servers to communicate through redis pubsub or whatever you prefer. | |
Handler that by default does not do anything since by default the library will not cache. | |
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 |
Query string to match username(s) and nickname(s) against | |
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. | |
Send a response to a users application command. The command data will have the id and token necessary to respond.
Interaction | |
Send a message to the channel. Requires SEND_MESSAGES permission. | |
sendInteractionResponse with ephemeral reply | |
Send a webhook with webhook Id and webhook token | |
Set changing text color to enabled or disabled | |
Split a url to separate rate limit buckets based on major/minor parameters. | |
Handler that by default will check to see if resharding should occur. Can be overriden if you have multiple servers and you want to communicate through redis pubsub or whatever you prefer. | |
Creates a new public thread from an existing message. Returns a thread channel. | |
Creates a new private thread. Returns a thread channel. | |
Trigger a typing indicator for the specified channel. Generally bots should NOT implement this route. However, if a bot is responding to a command and expects the computation to take a few seconds, this endpoint may be called to let the user know that the bot is processing their message. | |
Use this function to stop the gateway properly | |
Put horizontal line through the center of the text. | |
Remove ANSI escape codes from the string. | |
Suppress all the embeds in this message | |
Modify the positions of channels on the guild. Requires MANAGE_CHANNELS permission. Only channels to be modified are required. | |
Syncs the template to the guild's current state.
Requires the | |
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. | |
Sets a thread channel to be unarchived. | |
Remove the ban for a user. Requires BAN_MEMBERS permission | |
Make the text underline. | |
Sets a thread channel to be unlocked. | |
Updates the bot's voice state Caveats:
| |
Updates fields of an existing Stage instance. Requires the user to be a moderator of the Stage channel. | |
Updates the a user's voice state Caveats:
| |
Edit an existing application command. If this command did not exist, it will create it. | |
Bulk edit existing application commands. If a command does not exist, it will create it. | |
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 | |
I Role | |
I Team | |
I User | |
Type Aliases
T Id | |
https://discord.com/developers/docs/reference#image-formatting json is only for stickers | |