discord-api-wrapper
v2.2.0
Published
Interact with the discord API easier.
Downloads
49
Maintainers
Readme
Interact with the discord API easier.
This is a wrapper for the discord API. It is still in development and not all endpoints are implemented yet. If you want to help, feel free to make a pull request. Use the methods instead of manually making requests to the API. This will make it easier to use the API and you don't have to worry about the API changes.
🏠 Homepage
📝 Discord OAUTH2 API Documentation
📝 Discord User API Documentation
📝 Discord Guild API Documentation
Install
npm install discord-api-wrapper
Usage
const discordApiWrapper = require('discord-api-wrapper');
or
const { specificFunction } = require('discord-api-wrapper');
Methods
// Get the access_token from the code you got from the discord oauth2 redirect
exchangeAccessToken(client_id, client_secret, code, redirect_uri)
// Refresh the access_token by using the refresh_token
refreshAccessToken(client_id, client_secret, refresh_token)
// Get the logged in user information using the access_token
getLoggedInUserInformation(access_token)
// Get the logged in user connections using the access_token
getLoggedInUserConnections(access_token)
// Get all the guilds the logged in user is in using the access_token
getCurrentUserGuilds(access_token)
// Get the guild member object for the logged in user for a specific guild using the access_token and guild_id
getCurrentUserGuildMembers(access_token, guild_id)
// Get the guild icon url using the guild_id and icon_hash
// You get the guild icon hash from the getCurrentUserGuilds method and filtering the guilds
// NOTE: Future update to the package will include a method to get a specific guild so you dont have to filter
getGuildIcon(guild_id, icon_hash)
// Get the user avatar url using the user_id and avatar_hash
// You get the avatar hash from the getLoggedInUserInformation method
getAvatar(user_id, avatar_hash)
// Get the basic guild information using the access_token and guild_id
// NOTE you do not get the full guild object, only the basic information because of a discord limitation using the OAUTH2 access_code
// Use the getGuildById method to get the full guild object but this requires a bot token and the bot to be in that server
getGuildInfo(access_token, guild_id)
// Method to let the user join a guild
// NOTE You need a bot token to use this method
// NOTE The bot needs to be in the server you want the user to join with create instant invite permission
// NOTE The application needs to have the guilds.join scope
// Nick is optional
joinGuildByUserId(bot_token, user_id, guild_id, access_token, nick)
// Method to get a full guild object of a specific server
// NOTE You need a bot token to use this method
// NOTE The bot needs to be in the server you are trying to get
getGuildById(guild_id, bot_token)
// Method to make the authorized user join a guild by its id
// If join is successful it will return a server member object
// If the user is already in the guild it will return User is already in the guild!
// You need a bot token to use this method
joinGuildByUserId(bot_token, user_id, guild_id, access_token, nick)
// Method that returns an array of voice region objects that can be used when setting a voice or stage channel's rtc_region.
listVoiceRegions(bot_token)
// Method to create a webhook in a channel with a name and a audit log reason.
// Returns the webhook object on success
// See https://discord.com/developers/docs/resources/webhook#webhook-resource for webhook functions
createWebhook(bot_token, channel_id, name, reason)
// Method to get all webhooks in a channel
// Returns an array of webhook objects
getChannelWebhooks(bot_token, channel_id)
// Returns an array of webhook objects for every webhook in the specified guild
getGuildWebhooks(bot_token, guild_id)
// Returns the new webhook object for the given id uses the bot token for authorization
getWebhook(webhook_id, bot_token)
// Return the new webhook object for the given id and token does not require authorization
getWebhookWithToken(webhook_id, webhook_token)
// Modifies the webhook with the given id by changing its name and linked channel reason is showed in audit logs. Uses bot token for authorization.
modifyWebhook(webhook_id, bot_token, name, channel_id, reason)
// Modifies the webhook that was created with the given id and token. Does not require authorization.
modifyWebhookWithToken(webhook_id, webhook_token, name, channel_id, reason)
// Deletes the webhook with the given id. Requires bot token for authorization.
deleteWebhook(webhook_id, bot_token, reason)
// Deletes the webhook that was created with the given id and token. Does not require authorization.
deleteWebhookWithToken(webhook_id, webhook_token, reason)
// Executes webhook with the given id and token. Does not require authorization.
// NOTE: Will be updated to support more options in the future!
executeWebhook(webhook_id, webhook_token, content)
Author
👤 Nigel Christiaans [email protected]
- Github: @nigel12341
- LinkedIn: @n-christiaans
🤝 Contributing
Contributions, issues and feature requests are welcome!Feel free to check issues page. You can also take a look at the contributing guide.
Show your support
Give a ⭐️ if this project helped you!
📝 License
Copyright © 2023 Nigel Christiaans [email protected]. This project is MIT licensed.