discord_api
A wrapper in pure Dart to connect to Discord using OAuth2.
All the endpoints and objects are implemented as defined in the Discord API Reference
Getting Started
NOTE: This package is still in its early stage. While all models are supposedly implemented, they're not fully tested and all endpoints aren't implemented. Please do not hesitate to open a merge request if you added support for a specific endpoint !
This release isn't fully tested yet. Future releases will only happen once the currently available endpoints are fully-tested. Feel free to open an issue to make suggestions regarding which endpoints should be added in priority, depending on your needs.
To use this package, you will need to register an application on the Discord developer console to get a client ID and a client Secret.
After registering your application, you will need to instantiate the DiscordClient class from the package, with your clientId, clientSecret and your redirectUri.
You will also need to pass a DiscordHttpClient to it. You can either implement your own, or use the provided DiscordDioProvider. (Do note that this class will later be moved to its own package in order to remove the dio dependency on this package)
final _discordClient = DiscordClient(
clientId: clientId,
clientSecret: clientSecret,
redirectUri: redirectUri,
discordHttpClient:
DiscordDioProvider(clientId: clientId, clientSecret: clientSecret),
);
Now that you initialized the client, the last step before using the endpoints wrappers will be to manage the first connection with your Discord application, and initialize the Tokens you'll receive.
You can find a complete example of this in the example, using the package flutter_webview_plugin.
You can also use url_launcher with deep linking, use an external window in web as described in this article by my friend TesteurManiak, or any other method that you fancy depending on your targeted systems.
Supported Endpoints
Note: While theorically functional (and proven to be in human tests for most), those endpoints haven't yet been unitary tested.
User
xGet Current UserxGet UserxModify Current UserxGet Current User GuildsxGet Current User Guild MemberxLeave GuildxCreate DMCreate Group DMxGet Current User Connections
Guild
xGet GuildxGet Guild PreviewModify GuildDelete GuildCreate Guild ChannelModify Guild Channel PositionsList Active ThreadsGet Guild MemberList Guild MembersSearch Guild MembersAdd Guild MemberList Guild MembersSearch Guild MembersAdd Guild MemberModify Guild MemberModify Current MemberModify Current User NickAdd Guild Member RoleRemove Guild Member RoleRemove Guild MemberGet Guild BansGet Guild BanCreate Guild BanRemove Guild BanGet Guild RolesCreate Guild RoleModify Guild Role PositionsModify Guild RoleDelete Guild RoleGet Guild Prune CountBegin Guild PruneGet Guild Voice RegionsGet Guild InvitesGet Guild IntegrationsDelete Guild IntegrationGet Guild Widget SettingsModify Guild WidgetGet Guild WidgetGet Guild Vanity URLGet Guild Widget ImageGet Guild Welcome ScreenModify Guild Welcome ScreenModify Current User Voice StateModify User Voice State
Emoji
List Guild EmojisGet Guild EmojiCreate Guild EmojiModify Guild EmojiDelete Guild Emoji
Channel
Get ChannelModify ChannelDelete/Close ChannelGet Channel MessagesGet Channel MessageCreate MessageCrosspost MessageCreate ReactionDelete Own ReactionDelete User ReactionGet ReactionsDelete All ReactionsDelete All Reactions for EmojiEdit MessageDelete MessageBulk Delete MessagesEdit Channel PermissionsGet Channel InvitesCreate Channel InviteDelete Channel PermissionFollow News ChannelTrigger Typing IndicatorGet Pinned MessagesPin MessageUnpin MessageGroup DM Add RecipientGroup DM Remove RecipientStart Thread with MessageStart Thread without MessageJoin ThreadAdd Thread MemberLeave ThreadRemove Thread MemberGet Thread MemberList Thread MembersList Active ThreadsList Public Archived ThreadsList Private Archived ThreadsList Joined Private Archive Threads
Audit Logs
Get Guild Audit Log
Guild Scheduled Event
List Scheduled Events for GuildCreate Guild Scheduled EventGet Guild Scheduled EventModify Guild Scheduled EventDelete Guild Scheduled EventGet Guild Scheduled Event UsersGuild Scheduled Event Status Update AutomationGuild Scheduled Event Permissions Requirements
Guild Template
Get Guild TemplateCreate Guild from Guild TemplateGet Guild TemplatesCreate Guild TemplateSync Guild TemplateModify Guild TemplateDelete Guild Template
Invite
Get InviteDelete Invite
Stage Instance
Create Stage InstanceGet Stage InstanceModify Stage InstanceDelete Stage Instance
Sticker
Get StickerList Nitro Sticker PacksList Guild StickersGet Guild StickerCreate Guild StickerModify Guild StickerDelete Guild Sticker
Voice
List Voice Regions
Webhook
Create WebhookGet Channel WebhooksGet Guild WebhooksGet WebhookGet Webhook with TokenModify WebhookModify Webhook with TokenDelete WebhookDelete Webhook with TokenExecute WebhookExecute Slack-Compatible WebhookExecute GitHub-Compatible WebhookGet Webhook MessageEdit Webhook MessageDelete Webhook Message
OAuth2
Get Current Bot Application InformationGet Current Authorization Information