├── .github
└── workflows
│ └── dart.yml
├── .gitignore
├── .metadata
├── .pubignore
├── CHANGELOG.md
├── LICENSE
├── README.md
├── analysis_options.yaml
├── example
├── .gitignore
├── .metadata
├── README.md
├── analysis_options.yaml
├── android
│ ├── .gitignore
│ ├── app
│ │ ├── build.gradle
│ │ └── src
│ │ │ ├── debug
│ │ │ └── AndroidManifest.xml
│ │ │ ├── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── kotlin
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── example
│ │ │ │ │ └── MainActivity.kt
│ │ │ └── res
│ │ │ │ ├── drawable-v21
│ │ │ │ └── launch_background.xml
│ │ │ │ ├── drawable
│ │ │ │ └── launch_background.xml
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── values-night
│ │ │ │ └── styles.xml
│ │ │ │ └── values
│ │ │ │ └── styles.xml
│ │ │ └── profile
│ │ │ └── AndroidManifest.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ └── gradle-wrapper.properties
│ └── settings.gradle
├── ios
│ ├── .gitignore
│ ├── Flutter
│ │ ├── AppFrameworkInfo.plist
│ │ ├── Debug.xcconfig
│ │ └── Release.xcconfig
│ ├── Runner.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcshareddata
│ │ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ │ └── WorkspaceSettings.xcsettings
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── Runner.xcscheme
│ ├── Runner.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ └── WorkspaceSettings.xcsettings
│ └── Runner
│ │ ├── AppDelegate.swift
│ │ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ ├── Contents.json
│ │ │ ├── Icon-App-1024x1024@1x.png
│ │ │ ├── Icon-App-20x20@1x.png
│ │ │ ├── Icon-App-20x20@2x.png
│ │ │ ├── Icon-App-20x20@3x.png
│ │ │ ├── Icon-App-29x29@1x.png
│ │ │ ├── Icon-App-29x29@2x.png
│ │ │ ├── Icon-App-29x29@3x.png
│ │ │ ├── Icon-App-40x40@1x.png
│ │ │ ├── Icon-App-40x40@2x.png
│ │ │ ├── Icon-App-40x40@3x.png
│ │ │ ├── Icon-App-60x60@2x.png
│ │ │ ├── Icon-App-60x60@3x.png
│ │ │ ├── Icon-App-76x76@1x.png
│ │ │ ├── Icon-App-76x76@2x.png
│ │ │ └── Icon-App-83.5x83.5@2x.png
│ │ └── LaunchImage.imageset
│ │ │ ├── Contents.json
│ │ │ ├── LaunchImage.png
│ │ │ ├── LaunchImage@2x.png
│ │ │ ├── LaunchImage@3x.png
│ │ │ └── README.md
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ └── Runner-Bridging-Header.h
├── lib
│ ├── main.dart
│ └── webview_page.dart
├── pubspec.lock
├── pubspec.yaml
└── test
│ └── widget_test.dart
├── lib
├── discord_api.dart
└── src
│ ├── discord_cdn_helper.dart
│ ├── discord_client.dart
│ ├── exceptions
│ └── discord_api_exceptions.dart
│ ├── extensions
│ └── string_extensions.dart
│ ├── models
│ ├── discord_activity.dart
│ ├── discord_activity_assets.dart
│ ├── discord_activity_button.dart
│ ├── discord_activity_flag.dart
│ ├── discord_activity_party.dart
│ ├── discord_activity_secrets.dart
│ ├── discord_activity_timestamps.dart
│ ├── discord_activity_type.dart
│ ├── discord_allowed_mentions.dart
│ ├── discord_api_scope.dart
│ ├── discord_application.dart
│ ├── discord_application_flag.dart
│ ├── discord_attachment.dart
│ ├── discord_audit_log.dart
│ ├── discord_audit_log_change.dart
│ ├── discord_audit_log_change_key.dart
│ ├── discord_audit_log_entry.dart
│ ├── discord_audit_log_event.dart
│ ├── discord_authorization_information.dart
│ ├── discord_ban.dart
│ ├── discord_channel.dart
│ ├── discord_channel_mention.dart
│ ├── discord_channel_type.dart
│ ├── discord_client_status.dart
│ ├── discord_connection.dart
│ ├── discord_connection_visibility_type.dart
│ ├── discord_embed.dart
│ ├── discord_embed_author.dart
│ ├── discord_embed_field.dart
│ ├── discord_embed_footer.dart
│ ├── discord_embed_image.dart
│ ├── discord_embed_provider.dart
│ ├── discord_embed_thumbnail.dart
│ ├── discord_embed_type.dart
│ ├── discord_embed_video.dart
│ ├── discord_emoji.dart
│ ├── discord_errors.dart
│ ├── discord_explicit_content_filter_level.dart
│ ├── discord_followed_channel.dart
│ ├── discord_guild.dart
│ ├── discord_guild_feature.dart
│ ├── discord_guild_member.dart
│ ├── discord_guild_premium_tier.dart
│ ├── discord_guild_preview.dart
│ ├── discord_guild_scheduled_event.dart
│ ├── discord_guild_scheduled_event_entity_metadata.dart
│ ├── discord_guild_scheduled_event_entity_type.dart
│ ├── discord_guild_scheduled_event_privacy_level.dart
│ ├── discord_guild_scheduled_event_status.dart
│ ├── discord_guild_scheduled_event_user.dart
│ ├── discord_guild_template.dart
│ ├── discord_guild_widget.dart
│ ├── discord_guild_widget_settings.dart
│ ├── discord_image_format.dart
│ ├── discord_integration.dart
│ ├── discord_integration_account.dart
│ ├── discord_integration_application.dart
│ ├── discord_integration_expiration_behavior.dart
│ ├── discord_invite.dart
│ ├── discord_invite_metadata.dart
│ ├── discord_invite_stage_instance.dart
│ ├── discord_invite_target_type.dart
│ ├── discord_membership_state.dart
│ ├── discord_mention_type.dart
│ ├── discord_message.dart
│ ├── discord_message_activity.dart
│ ├── discord_message_activity_type.dart
│ ├── discord_message_component.dart
│ ├── discord_message_component_type.dart
│ ├── discord_message_flag.dart
│ ├── discord_message_interaction.dart
│ ├── discord_message_interaction_type.dart
│ ├── discord_message_notifications_level.dart
│ ├── discord_message_reference.dart
│ ├── discord_message_type.dart
│ ├── discord_mfa_level.dart
│ ├── discord_nsfw_level.dart
│ ├── discord_optional_audit_entry_info.dart
│ ├── discord_overwrite.dart
│ ├── discord_overwrite_type.dart
│ ├── discord_premium_type.dart
│ ├── discord_presence_update.dart
│ ├── discord_reaction.dart
│ ├── discord_role.dart
│ ├── discord_role_tags.dart
│ ├── discord_snowflake.dart
│ ├── discord_stage_instance.dart
│ ├── discord_stage_privacy_level.dart
│ ├── discord_status.dart
│ ├── discord_sticker.dart
│ ├── discord_sticker_format_type.dart
│ ├── discord_sticker_item.dart
│ ├── discord_sticker_pack.dart
│ ├── discord_sticker_type.dart
│ ├── discord_system_channel_flag.dart
│ ├── discord_team.dart
│ ├── discord_team_member.dart
│ ├── discord_thread_member.dart
│ ├── discord_thread_metadata.dart
│ ├── discord_token.dart
│ ├── discord_token_webhook.dart
│ ├── discord_user.dart
│ ├── discord_user_flag.dart
│ ├── discord_verification_level.dart
│ ├── discord_video_quality_mode.dart
│ ├── discord_visibility_type.dart
│ ├── discord_voice_region.dart
│ ├── discord_voice_state.dart
│ ├── discord_webhook.dart
│ ├── discord_welcome_screen.dart
│ └── discord_welcome_screen_channel.dart
│ └── providers
│ ├── discord_dio_provider.dart
│ └── discord_http_client.dart
├── pubspec.yaml
└── test
└── discord_api_test.dart
/.github/workflows/dart.yml:
--------------------------------------------------------------------------------
1 | # This workflow uses actions that are not certified by GitHub.
2 | # They are provided by a third-party and are governed by
3 | # separate terms of service, privacy policy, and support
4 | # documentation.
5 |
6 | name: Dart
7 |
8 | on:
9 | push:
10 | branches: [ main, dev ]
11 | pull_request:
12 | branches: [ main, dev ]
13 |
14 | jobs:
15 | build:
16 | runs-on: ubuntu-latest
17 | steps:
18 | - uses: actions/checkout@v2
19 | - uses: dart-lang/setup-dart@v1
20 | - name: Install dependencies
21 | run: dart pub get
22 | - name: Analyze project source
23 | run: dart analyze
24 | working-directory: ./lib
25 | - name: Run tests
26 | run: dart test --coverage="coverage"
27 | # - name: Generate Lcov
28 | # run: dart pub run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --packages=.packages --report-on=lib
29 | # - name: Collect and report coverage
30 | # uses: coverallsapp/github-action@v1.1.2
31 | # with:
32 | # github-token: ${{ secrets.GITHUB_TOKEN }}
33 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 | .fvm/
12 |
13 | # IntelliJ related
14 | *.iml
15 | *.ipr
16 | *.iws
17 | .idea/
18 |
19 | # The .vscode folder contains launch configuration and tasks you configure in
20 | # VS Code which you may wish to be included in version control, so this line
21 | # is commented out by default.
22 | #.vscode/
23 |
24 | # Flutter/Dart/Pub related
25 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
26 | /pubspec.lock
27 | **/doc/api/
28 | .dart_tool/
29 | .packages
30 | build/
31 |
--------------------------------------------------------------------------------
/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: db747aa1331bd95bc9b3874c842261ca2d302cd5
8 | channel: stable
9 |
10 | project_type: package
11 |
--------------------------------------------------------------------------------
/.pubignore:
--------------------------------------------------------------------------------
1 | # See https://dart.dev/tools/pub/publishing#what-files-are-published
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 0.1.1
2 |
3 | * Updated GitHub Links, as the repository was renamed from discord_api_flutter to discord_api.
4 | * Remove .pubignore file to include `/example` directory in the pub package
5 | * Gave the package a longer description in the `pubspec.yaml` file
6 |
7 | ## 0.1.0
8 |
9 | * **Initial Release**
10 |
--------------------------------------------------------------------------------
/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | include: package:lint/analysis_options.yaml
2 |
3 | analyzer:
4 | exclude:
5 | - lib/**.g.dart
6 | - test/**.mocks.dart
7 | - lib/generated_plugin_registrant.dart
8 | strong-mode:
9 | implicit-casts: false
10 | errors:
11 | missing_required_param: error
12 | unrelated_type_equality_checks: error
13 | missing_return: warning
14 | close_sinks: warning
15 | cancel_subscriptions: warning
16 | parameter_assignments: warning
17 | prefer_final_in_for_each: warning
18 | prefer_mixin: warning
19 | unawaited_futures: warning
20 | unnecessary_await_in_return: warning
21 | unnecessary_null_aware_assignments: warning
22 | use_string_buffers: warning
23 |
24 | linter:
25 | rules:
26 | always_use_package_imports: false
27 | prefer_relative_imports: true
28 | use_string_buffers: true
29 | use_if_null_to_convert_nulls_to_bools: true
30 | parameter_assignments: true
31 | prefer_null_aware_method_calls: true
32 | use_is_even_rather_than_modulo: true
33 | prefer_final_in_for_each: true
34 | directives_ordering: true
35 | avoid_unused_constructor_parameters: true
36 | prefer_final_locals: true
--------------------------------------------------------------------------------
/example/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 |
12 | # IntelliJ related
13 | *.iml
14 | *.ipr
15 | *.iws
16 | .idea/
17 |
18 | # The .vscode folder contains launch configuration and tasks you configure in
19 | # VS Code which you may wish to be included in version control, so this line
20 | # is commented out by default.
21 | #.vscode/
22 |
23 | # Flutter/Dart/Pub related
24 | **/doc/api/
25 | **/ios/Flutter/.last_build_id
26 | .dart_tool/
27 | .flutter-plugins
28 | .flutter-plugins-dependencies
29 | .packages
30 | .pub-cache/
31 | .pub/
32 | /build/
33 | /windows/*
34 | /web/*
35 |
36 | # Web related
37 | lib/generated_plugin_registrant.dart
38 |
39 | # Symbolication related
40 | app.*.symbols
41 |
42 | # Obfuscation related
43 | app.*.map.json
44 |
45 | # Android Studio will place build artifacts here
46 | /android/app/debug
47 | /android/app/profile
48 | /android/app/release
49 |
--------------------------------------------------------------------------------
/example/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: db747aa1331bd95bc9b3874c842261ca2d302cd5
8 | channel: stable
9 |
10 | project_type: app
11 |
--------------------------------------------------------------------------------
/example/README.md:
--------------------------------------------------------------------------------
1 | # example
2 |
3 | A new Flutter project.
4 |
5 | ## Getting Started
6 |
7 | This project is a starting point for a Flutter application.
8 |
9 | A few resources to get you started if this is your first Flutter project:
10 |
11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
13 |
14 | For help getting started with Flutter, view our
15 | [online documentation](https://flutter.dev/docs), which offers tutorials,
16 | samples, guidance on mobile development, and a full API reference.
17 |
--------------------------------------------------------------------------------
/example/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | # This file configures the analyzer, which statically analyzes Dart code to
2 | # check for errors, warnings, and lints.
3 | #
4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6 | # invoked from the command line by running `flutter analyze`.
7 |
8 | # The following line activates a set of recommended lints for Flutter apps,
9 | # packages, and plugins designed to encourage good coding practices.
10 | include: package:flutter_lints/flutter.yaml
11 |
12 | linter:
13 | # The lint rules applied to this project can be customized in the
14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml`
15 | # included above or to enable additional rules. A list of all available lints
16 | # and their documentation is published at
17 | # https://dart-lang.github.io/linter/lints/index.html.
18 | #
19 | # Instead of disabling a lint rule for the entire project in the
20 | # section below, it can also be suppressed for a single line of code
21 | # or a specific dart file by using the `// ignore: name_of_lint` and
22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file
23 | # producing the lint.
24 | rules:
25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule
26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
27 |
28 | # Additional information about this file can be found at
29 | # https://dart.dev/guides/language/analysis-options
30 |
--------------------------------------------------------------------------------
/example/android/.gitignore:
--------------------------------------------------------------------------------
1 | gradle-wrapper.jar
2 | /.gradle
3 | /captures/
4 | /gradlew
5 | /gradlew.bat
6 | /local.properties
7 | GeneratedPluginRegistrant.java
8 |
9 | # Remember to never publicly share your keystore.
10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
11 | key.properties
12 | **/*.keystore
13 | **/*.jks
14 |
--------------------------------------------------------------------------------
/example/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | def localProperties = new Properties()
2 | def localPropertiesFile = rootProject.file('local.properties')
3 | if (localPropertiesFile.exists()) {
4 | localPropertiesFile.withReader('UTF-8') { reader ->
5 | localProperties.load(reader)
6 | }
7 | }
8 |
9 | def flutterRoot = localProperties.getProperty('flutter.sdk')
10 | if (flutterRoot == null) {
11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12 | }
13 |
14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15 | if (flutterVersionCode == null) {
16 | flutterVersionCode = '1'
17 | }
18 |
19 | def flutterVersionName = localProperties.getProperty('flutter.versionName')
20 | if (flutterVersionName == null) {
21 | flutterVersionName = '1.0'
22 | }
23 |
24 | apply plugin: 'com.android.application'
25 | apply plugin: 'kotlin-android'
26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27 |
28 | android {
29 | compileSdkVersion flutter.compileSdkVersion
30 |
31 | compileOptions {
32 | sourceCompatibility JavaVersion.VERSION_1_8
33 | targetCompatibility JavaVersion.VERSION_1_8
34 | }
35 |
36 | kotlinOptions {
37 | jvmTarget = '1.8'
38 | }
39 |
40 | sourceSets {
41 | main.java.srcDirs += 'src/main/kotlin'
42 | }
43 |
44 | defaultConfig {
45 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
46 | applicationId "com.example.example"
47 | minSdkVersion flutter.minSdkVersion
48 | targetSdkVersion flutter.targetSdkVersion
49 | versionCode flutterVersionCode.toInteger()
50 | versionName flutterVersionName
51 | }
52 |
53 | buildTypes {
54 | release {
55 | // TODO: Add your own signing config for the release build.
56 | // Signing with the debug keys for now, so `flutter run --release` works.
57 | signingConfig signingConfigs.debug
58 | }
59 | }
60 | }
61 |
62 | flutter {
63 | source '../..'
64 | }
65 |
66 | dependencies {
67 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
68 | }
69 |
--------------------------------------------------------------------------------
/example/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
7 |
15 |
19 |
23 |
24 |
25 |
26 |
27 |
28 |
30 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.example.example
2 |
3 | import io.flutter.embedding.android.FlutterActivity
4 |
5 | class MainActivity: FlutterActivity() {
6 | }
7 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable-v21/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MeixDev/discord_api/3cb836325bccc9ec131945c93c7990daad6acec0/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MeixDev/discord_api/3cb836325bccc9ec131945c93c7990daad6acec0/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MeixDev/discord_api/3cb836325bccc9ec131945c93c7990daad6acec0/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MeixDev/discord_api/3cb836325bccc9ec131945c93c7990daad6acec0/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MeixDev/discord_api/3cb836325bccc9ec131945c93c7990daad6acec0/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values-night/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/example/android/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext.kotlin_version = '1.6.10'
3 | repositories {
4 | google()
5 | mavenCentral()
6 | }
7 |
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:4.1.0'
10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | google()
17 | mavenCentral()
18 | }
19 | }
20 |
21 | rootProject.buildDir = '../build'
22 | subprojects {
23 | project.buildDir = "${rootProject.buildDir}/${project.name}"
24 | }
25 | subprojects {
26 | project.evaluationDependsOn(':app')
27 | }
28 |
29 | task clean(type: Delete) {
30 | delete rootProject.buildDir
31 | }
32 |
--------------------------------------------------------------------------------
/example/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.useAndroidX=true
3 | android.enableJetifier=true
4 |
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jun 23 08:50:38 CEST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
7 |
--------------------------------------------------------------------------------
/example/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4 | def properties = new Properties()
5 |
6 | assert localPropertiesFile.exists()
7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
8 |
9 | def flutterSdkPath = properties.getProperty("flutter.sdk")
10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
12 |
--------------------------------------------------------------------------------
/example/ios/.gitignore:
--------------------------------------------------------------------------------
1 | **/dgph
2 | *.mode1v3
3 | *.mode2v3
4 | *.moved-aside
5 | *.pbxuser
6 | *.perspectivev3
7 | **/*sync/
8 | .sconsign.dblite
9 | .tags*
10 | **/.vagrant/
11 | **/DerivedData/
12 | Icon?
13 | **/Pods/
14 | **/.symlinks/
15 | profile
16 | xcuserdata
17 | **/.generated/
18 | Flutter/App.framework
19 | Flutter/Flutter.framework
20 | Flutter/Flutter.podspec
21 | Flutter/Generated.xcconfig
22 | Flutter/ephemeral/
23 | Flutter/app.flx
24 | Flutter/app.zip
25 | Flutter/flutter_assets/
26 | Flutter/flutter_export_environment.sh
27 | ServiceDefinitions.json
28 | Runner/GeneratedPluginRegistrant.*
29 |
30 | # Exceptions to above rules.
31 | !default.mode1v3
32 | !default.mode2v3
33 | !default.pbxuser
34 | !default.perspectivev3
35 |
--------------------------------------------------------------------------------
/example/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | App
9 | CFBundleIdentifier
10 | io.flutter.flutter.app
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | App
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | MinimumOSVersion
24 | 9.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/example/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
37 |
38 |
39 |
40 |
41 |
42 |
52 |
54 |
60 |
61 |
62 |
63 |
69 |
71 |
77 |
78 |
79 |
80 |
82 |
83 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 | import Flutter
3 |
4 | @UIApplicationMain
5 | @objc class AppDelegate: FlutterAppDelegate {
6 | override func application(
7 | _ application: UIApplication,
8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
9 | ) -> Bool {
10 | GeneratedPluginRegistrant.register(with: self)
11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "20x20",
5 | "idiom" : "iphone",
6 | "filename" : "Icon-App-20x20@2x.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "20x20",
11 | "idiom" : "iphone",
12 | "filename" : "Icon-App-20x20@3x.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "Icon-App-29x29@1x.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "29x29",
23 | "idiom" : "iphone",
24 | "filename" : "Icon-App-29x29@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "29x29",
29 | "idiom" : "iphone",
30 | "filename" : "Icon-App-29x29@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "40x40",
35 | "idiom" : "iphone",
36 | "filename" : "Icon-App-40x40@2x.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "40x40",
41 | "idiom" : "iphone",
42 | "filename" : "Icon-App-40x40@3x.png",
43 | "scale" : "3x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "Icon-App-60x60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "Icon-App-60x60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "20x20",
59 | "idiom" : "ipad",
60 | "filename" : "Icon-App-20x20@1x.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "20x20",
65 | "idiom" : "ipad",
66 | "filename" : "Icon-App-20x20@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "29x29",
71 | "idiom" : "ipad",
72 | "filename" : "Icon-App-29x29@1x.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "29x29",
77 | "idiom" : "ipad",
78 | "filename" : "Icon-App-29x29@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "40x40",
83 | "idiom" : "ipad",
84 | "filename" : "Icon-App-40x40@1x.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "40x40",
89 | "idiom" : "ipad",
90 | "filename" : "Icon-App-40x40@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "76x76",
95 | "idiom" : "ipad",
96 | "filename" : "Icon-App-76x76@1x.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "76x76",
101 | "idiom" : "ipad",
102 | "filename" : "Icon-App-76x76@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "83.5x83.5",
107 | "idiom" : "ipad",
108 | "filename" : "Icon-App-83.5x83.5@2x.png",
109 | "scale" : "2x"
110 | },
111 | {
112 | "size" : "1024x1024",
113 | "idiom" : "ios-marketing",
114 | "filename" : "Icon-App-1024x1024@1x.png",
115 | "scale" : "1x"
116 | }
117 | ],
118 | "info" : {
119 | "version" : 1,
120 | "author" : "xcode"
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MeixDev/discord_api/3cb836325bccc9ec131945c93c7990daad6acec0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MeixDev/discord_api/3cb836325bccc9ec131945c93c7990daad6acec0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MeixDev/discord_api/3cb836325bccc9ec131945c93c7990daad6acec0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MeixDev/discord_api/3cb836325bccc9ec131945c93c7990daad6acec0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MeixDev/discord_api/3cb836325bccc9ec131945c93c7990daad6acec0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MeixDev/discord_api/3cb836325bccc9ec131945c93c7990daad6acec0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MeixDev/discord_api/3cb836325bccc9ec131945c93c7990daad6acec0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MeixDev/discord_api/3cb836325bccc9ec131945c93c7990daad6acec0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MeixDev/discord_api/3cb836325bccc9ec131945c93c7990daad6acec0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MeixDev/discord_api/3cb836325bccc9ec131945c93c7990daad6acec0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MeixDev/discord_api/3cb836325bccc9ec131945c93c7990daad6acec0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MeixDev/discord_api/3cb836325bccc9ec131945c93c7990daad6acec0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MeixDev/discord_api/3cb836325bccc9ec131945c93c7990daad6acec0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MeixDev/discord_api/3cb836325bccc9ec131945c93c7990daad6acec0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MeixDev/discord_api/3cb836325bccc9ec131945c93c7990daad6acec0/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchImage.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchImage@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "LaunchImage@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MeixDev/discord_api/3cb836325bccc9ec131945c93c7990daad6acec0/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MeixDev/discord_api/3cb836325bccc9ec131945c93c7990daad6acec0/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MeixDev/discord_api/3cb836325bccc9ec131945c93c7990daad6acec0/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md:
--------------------------------------------------------------------------------
1 | # Launch Screen Assets
2 |
3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory.
4 |
5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
--------------------------------------------------------------------------------
/example/ios/Runner/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/example/ios/Runner/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleDisplayName
8 | Example
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | example
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | $(FLUTTER_BUILD_NAME)
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | $(FLUTTER_BUILD_NUMBER)
25 | LSRequiresIPhoneOS
26 |
27 | UILaunchStoryboardName
28 | LaunchScreen
29 | UIMainStoryboardFile
30 | Main
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 | UIViewControllerBasedStatusBarAppearance
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/example/ios/Runner/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | #import "GeneratedPluginRegistrant.h"
2 |
--------------------------------------------------------------------------------
/example/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:discord_api/discord_api.dart';
3 | import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
4 |
5 | import 'webview_page.dart';
6 |
7 | const clientId = 'CLIENT_ID';
8 | const clientSecret = 'CLIENT_SECRET';
9 | const redirectUri = 'http://localhost:8080/callback';
10 |
11 | void main() {
12 | runApp(const MyApp());
13 | }
14 |
15 | class MyApp extends StatelessWidget {
16 | const MyApp({Key? key}) : super(key: key);
17 |
18 | // This widget is the root of your application.
19 | @override
20 | Widget build(BuildContext context) {
21 | return MaterialApp(
22 | title: 'Discord API Demo',
23 | theme: ThemeData(
24 | primarySwatch: Colors.blue,
25 | visualDensity: VisualDensity.adaptivePlatformDensity,
26 | ),
27 | home: const MyHomePage(title: 'Discord API Demo'),
28 | );
29 | }
30 | }
31 |
32 | class MyHomePage extends StatefulWidget {
33 | const MyHomePage({Key? key, required this.title}) : super(key: key);
34 |
35 | final String title;
36 |
37 | @override
38 | State createState() => _MyHomePageState();
39 | }
40 |
41 | class _MyHomePageState extends State {
42 | final _discordClient = DiscordClient(
43 | clientId: clientId,
44 | clientSecret: clientSecret,
45 | redirectUri: redirectUri,
46 | discordHttpClient:
47 | DiscordDioProvider(clientId: clientId, clientSecret: clientSecret),
48 | );
49 |
50 | final _flutterWebviewPlugin = FlutterWebviewPlugin();
51 |
52 | void _urlListener(String url) {
53 | if (url.startsWith(redirectUri)) {
54 | final code = Uri.parse(url).queryParameters['code'];
55 | if (code != null) {
56 | _discordClient.getAccessToken(code).then((token) {
57 | _flutterWebviewPlugin.close();
58 | setState(() {});
59 | });
60 | }
61 | }
62 | }
63 |
64 | Future _openConnectionPage(
65 | {List scopes = const []}) {
66 | _flutterWebviewPlugin.onUrlChanged.listen(_urlListener);
67 | _flutterWebviewPlugin.onDestroy.listen((_) => Navigator.pop(context));
68 |
69 | final url = _discordClient.authorizeUri(scopes);
70 |
71 | return Navigator.push(
72 | context,
73 | MaterialPageRoute(
74 | builder: (context) => WebViewPage(url.toString()),
75 | ),
76 | ).then((_) {
77 | if (_discordClient.discordHttpClient.discordToken != null) {
78 | debugPrint(
79 | "TOKEN: ${_discordClient.discordHttpClient.discordToken?.accessToken}");
80 | return _discordClient.discordHttpClient.discordToken;
81 | }
82 | return null;
83 | });
84 | }
85 |
86 | @override
87 | void initState() {
88 | super.initState();
89 | WidgetsBinding.instance?.scheduleFrameCallback((timeStamp) {
90 | _openConnectionPage(
91 | scopes: [
92 | DiscordApiScope.identify,
93 | DiscordApiScope.email,
94 | DiscordApiScope.guilds
95 | ],
96 | ).then((value) => setState(() {}));
97 | });
98 | }
99 |
100 | void _displayDataAlert({
101 | String? method,
102 | String? data,
103 | bool isImg = false,
104 | bool? isOnline,
105 | }) {
106 | showDialog(
107 | context: context,
108 | builder: (context) {
109 | return AlertDialog(
110 | title: Text(method ?? ''),
111 | content: Column(
112 | crossAxisAlignment: CrossAxisAlignment.start,
113 | mainAxisSize: MainAxisSize.min,
114 | children: [
115 | if (isOnline != null)
116 | Text(
117 | isOnline ? 'Online' : 'Offline',
118 | style: TextStyle(
119 | color: isOnline ? Colors.green : Colors.red,
120 | fontWeight: FontWeight.bold,
121 | ),
122 | ),
123 | if (!isImg && data != null) Text(data),
124 | if (isImg && data != null)
125 | Image.network(
126 | data,
127 | loadingBuilder: (_, __, ___) =>
128 | const CircularProgressIndicator(),
129 | ),
130 | ],
131 | ),
132 | );
133 | },
134 | );
135 | }
136 |
137 | @override
138 | Widget build(BuildContext context) {
139 | return Scaffold(
140 | appBar: AppBar(
141 | title: Text(widget.title),
142 | ),
143 | body: ListView(
144 | children: [
145 | // Text(
146 | // 'Welcome user: ${_discordClient.discordHttpClient.discordToken?.userId}',
147 | // ),
148 | Text(
149 | 'Your Discord access token is: ${_discordClient.discordHttpClient.discordToken?.accessToken}',
150 | ),
151 | ElevatedButton(
152 | onPressed: () async {
153 | final user = await _discordClient.getCurrentUser();
154 | _displayDataAlert(
155 | method: 'getCurrentUser',
156 | data: user.toString(),
157 | );
158 | },
159 | child: const Text('Get Me'),
160 | ),
161 | ],
162 | ),
163 | );
164 | }
165 | }
166 |
--------------------------------------------------------------------------------
/example/lib/webview_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
3 |
4 | class WebViewPage extends StatelessWidget {
5 | final String url;
6 |
7 | const WebViewPage(this.url, {Key? key}) : super(key: key);
8 |
9 | @override
10 | Widget build(BuildContext context) {
11 | return WebviewScaffold(appBar: AppBar(), url: url);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/example/pubspec.lock:
--------------------------------------------------------------------------------
1 | # Generated by pub
2 | # See https://dart.dev/tools/pub/glossary#lockfile
3 | packages:
4 | async:
5 | dependency: transitive
6 | description:
7 | name: async
8 | url: "https://pub.dartlang.org"
9 | source: hosted
10 | version: "2.8.2"
11 | boolean_selector:
12 | dependency: transitive
13 | description:
14 | name: boolean_selector
15 | url: "https://pub.dartlang.org"
16 | source: hosted
17 | version: "2.1.0"
18 | characters:
19 | dependency: transitive
20 | description:
21 | name: characters
22 | url: "https://pub.dartlang.org"
23 | source: hosted
24 | version: "1.2.0"
25 | charcode:
26 | dependency: transitive
27 | description:
28 | name: charcode
29 | url: "https://pub.dartlang.org"
30 | source: hosted
31 | version: "1.3.1"
32 | clock:
33 | dependency: transitive
34 | description:
35 | name: clock
36 | url: "https://pub.dartlang.org"
37 | source: hosted
38 | version: "1.1.0"
39 | collection:
40 | dependency: transitive
41 | description:
42 | name: collection
43 | url: "https://pub.dartlang.org"
44 | source: hosted
45 | version: "1.15.0"
46 | cupertino_icons:
47 | dependency: "direct main"
48 | description:
49 | name: cupertino_icons
50 | url: "https://pub.dartlang.org"
51 | source: hosted
52 | version: "1.0.4"
53 | dio:
54 | dependency: transitive
55 | description:
56 | name: dio
57 | url: "https://pub.dartlang.org"
58 | source: hosted
59 | version: "4.0.4"
60 | discord_api:
61 | dependency: "direct main"
62 | description:
63 | path: ".."
64 | relative: true
65 | source: path
66 | version: "0.1.0"
67 | fake_async:
68 | dependency: transitive
69 | description:
70 | name: fake_async
71 | url: "https://pub.dartlang.org"
72 | source: hosted
73 | version: "1.2.0"
74 | flutter:
75 | dependency: "direct main"
76 | description: flutter
77 | source: sdk
78 | version: "0.0.0"
79 | flutter_lints:
80 | dependency: "direct dev"
81 | description:
82 | name: flutter_lints
83 | url: "https://pub.dartlang.org"
84 | source: hosted
85 | version: "1.0.4"
86 | flutter_test:
87 | dependency: "direct dev"
88 | description: flutter
89 | source: sdk
90 | version: "0.0.0"
91 | flutter_webview_plugin:
92 | dependency: "direct dev"
93 | description:
94 | name: flutter_webview_plugin
95 | url: "https://pub.dartlang.org"
96 | source: hosted
97 | version: "0.4.0"
98 | http_parser:
99 | dependency: transitive
100 | description:
101 | name: http_parser
102 | url: "https://pub.dartlang.org"
103 | source: hosted
104 | version: "4.0.0"
105 | lints:
106 | dependency: transitive
107 | description:
108 | name: lints
109 | url: "https://pub.dartlang.org"
110 | source: hosted
111 | version: "1.0.1"
112 | matcher:
113 | dependency: transitive
114 | description:
115 | name: matcher
116 | url: "https://pub.dartlang.org"
117 | source: hosted
118 | version: "0.12.11"
119 | material_color_utilities:
120 | dependency: transitive
121 | description:
122 | name: material_color_utilities
123 | url: "https://pub.dartlang.org"
124 | source: hosted
125 | version: "0.1.3"
126 | meta:
127 | dependency: transitive
128 | description:
129 | name: meta
130 | url: "https://pub.dartlang.org"
131 | source: hosted
132 | version: "1.7.0"
133 | path:
134 | dependency: transitive
135 | description:
136 | name: path
137 | url: "https://pub.dartlang.org"
138 | source: hosted
139 | version: "1.8.1"
140 | sky_engine:
141 | dependency: transitive
142 | description: flutter
143 | source: sdk
144 | version: "0.0.99"
145 | source_span:
146 | dependency: transitive
147 | description:
148 | name: source_span
149 | url: "https://pub.dartlang.org"
150 | source: hosted
151 | version: "1.8.1"
152 | stack_trace:
153 | dependency: transitive
154 | description:
155 | name: stack_trace
156 | url: "https://pub.dartlang.org"
157 | source: hosted
158 | version: "1.10.0"
159 | stream_channel:
160 | dependency: transitive
161 | description:
162 | name: stream_channel
163 | url: "https://pub.dartlang.org"
164 | source: hosted
165 | version: "2.1.0"
166 | string_scanner:
167 | dependency: transitive
168 | description:
169 | name: string_scanner
170 | url: "https://pub.dartlang.org"
171 | source: hosted
172 | version: "1.1.0"
173 | term_glyph:
174 | dependency: transitive
175 | description:
176 | name: term_glyph
177 | url: "https://pub.dartlang.org"
178 | source: hosted
179 | version: "1.2.0"
180 | test_api:
181 | dependency: transitive
182 | description:
183 | name: test_api
184 | url: "https://pub.dartlang.org"
185 | source: hosted
186 | version: "0.4.9"
187 | typed_data:
188 | dependency: transitive
189 | description:
190 | name: typed_data
191 | url: "https://pub.dartlang.org"
192 | source: hosted
193 | version: "1.3.0"
194 | vector_math:
195 | dependency: transitive
196 | description:
197 | name: vector_math
198 | url: "https://pub.dartlang.org"
199 | source: hosted
200 | version: "2.1.1"
201 | sdks:
202 | dart: ">=2.16.1 <3.0.0"
203 | flutter: ">=2.0.0"
204 |
--------------------------------------------------------------------------------
/example/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: example
2 | description: A new Flutter project.
3 |
4 | publish_to: 'none'
5 |
6 | version: 1.0.0+1
7 |
8 | environment:
9 | sdk: ">=2.16.1 <3.0.0"
10 |
11 | dependencies:
12 | cupertino_icons: ^1.0.2
13 | flutter:
14 | sdk: flutter
15 | discord_api:
16 | path: ../
17 |
18 | dev_dependencies:
19 | flutter_test:
20 | sdk: flutter
21 |
22 | flutter_webview_plugin: ^0.4.0
23 | flutter_lints: ^1.0.0
24 |
25 | flutter:
26 |
27 | uses-material-design: true
--------------------------------------------------------------------------------
/example/test/widget_test.dart:
--------------------------------------------------------------------------------
1 | // This is a basic Flutter widget test.
2 | //
3 | // To perform an interaction with a widget in your test, use the WidgetTester
4 | // utility that Flutter provides. For example, you can send tap and scroll
5 | // gestures. You can also use WidgetTester to find child widgets in the widget
6 | // tree, read text, and verify that the values of widget properties are correct.
7 |
8 | import 'package:flutter/material.dart';
9 | import 'package:flutter_test/flutter_test.dart';
10 |
11 | import 'package:example/main.dart';
12 |
13 | void main() {
14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async {
15 | // Build our app and trigger a frame.
16 | await tester.pumpWidget(const MyApp());
17 |
18 | // Verify that our counter starts at 0.
19 | expect(find.text('0'), findsOneWidget);
20 | expect(find.text('1'), findsNothing);
21 |
22 | // Tap the '+' icon and trigger a frame.
23 | await tester.tap(find.byIcon(Icons.add));
24 | await tester.pump();
25 |
26 | // Verify that our counter has incremented.
27 | expect(find.text('0'), findsNothing);
28 | expect(find.text('1'), findsOneWidget);
29 | });
30 | }
31 |
--------------------------------------------------------------------------------
/lib/discord_api.dart:
--------------------------------------------------------------------------------
1 | library discord_api;
2 |
3 | export 'src/discord_cdn_helper.dart';
4 | export 'src/discord_client.dart';
5 | export 'src/exceptions/discord_api_exceptions.dart';
6 | export 'src/extensions/string_extensions.dart';
7 | export 'src/models/discord_activity.dart';
8 | export 'src/models/discord_activity_assets.dart';
9 | export 'src/models/discord_activity_button.dart';
10 | export 'src/models/discord_activity_flag.dart';
11 | export 'src/models/discord_activity_party.dart';
12 | export 'src/models/discord_activity_secrets.dart';
13 | export 'src/models/discord_activity_timestamps.dart';
14 | export 'src/models/discord_activity_type.dart';
15 | export 'src/models/discord_allowed_mentions.dart';
16 | export 'src/models/discord_api_scope.dart';
17 | export 'src/models/discord_application.dart';
18 | export 'src/models/discord_application_flag.dart';
19 | export 'src/models/discord_attachment.dart';
20 | export 'src/models/discord_audit_log.dart';
21 | export 'src/models/discord_audit_log_change.dart';
22 | export 'src/models/discord_audit_log_change_key.dart';
23 | export 'src/models/discord_audit_log_entry.dart';
24 | export 'src/models/discord_authorization_information.dart';
25 | export 'src/models/discord_ban.dart';
26 | export 'src/models/discord_channel.dart';
27 | export 'src/models/discord_channel_mention.dart';
28 | export 'src/models/discord_channel_type.dart';
29 | export 'src/models/discord_client_status.dart';
30 | export 'src/models/discord_connection.dart';
31 | export 'src/models/discord_connection_visibility_type.dart';
32 | export 'src/models/discord_embed.dart';
33 | export 'src/models/discord_embed_author.dart';
34 | export 'src/models/discord_embed_field.dart';
35 | export 'src/models/discord_embed_footer.dart';
36 | export 'src/models/discord_embed_image.dart';
37 | export 'src/models/discord_embed_provider.dart';
38 | export 'src/models/discord_embed_thumbnail.dart';
39 | export 'src/models/discord_embed_type.dart';
40 | export 'src/models/discord_embed_video.dart';
41 | export 'src/models/discord_emoji.dart';
42 | export 'src/models/discord_errors.dart';
43 | export 'src/models/discord_explicit_content_filter_level.dart';
44 | export 'src/models/discord_followed_channel.dart';
45 | export 'src/models/discord_guild.dart';
46 | export 'src/models/discord_guild_feature.dart';
47 | export 'src/models/discord_guild_member.dart';
48 | export 'src/models/discord_guild_premium_tier.dart';
49 | export 'src/models/discord_guild_preview.dart';
50 | export 'src/models/discord_guild_scheduled_event.dart';
51 | export 'src/models/discord_guild_scheduled_event_entity_metadata.dart';
52 | export 'src/models/discord_guild_scheduled_event_entity_type.dart';
53 | export 'src/models/discord_guild_scheduled_event_privacy_level.dart';
54 | export 'src/models/discord_guild_scheduled_event_status.dart';
55 | export 'src/models/discord_guild_scheduled_event_user.dart';
56 | export 'src/models/discord_guild_template.dart';
57 | export 'src/models/discord_guild_widget.dart';
58 | export 'src/models/discord_guild_widget_settings.dart';
59 | export 'src/models/discord_image_format.dart';
60 | export 'src/models/discord_integration.dart';
61 | export 'src/models/discord_integration_account.dart';
62 | export 'src/models/discord_integration_application.dart';
63 | export 'src/models/discord_integration_expiration_behavior.dart';
64 | export 'src/models/discord_invite.dart';
65 | export 'src/models/discord_invite_metadata.dart';
66 | export 'src/models/discord_invite_stage_instance.dart';
67 | export 'src/models/discord_invite_target_type.dart';
68 | export 'src/models/discord_membership_state.dart';
69 | export 'src/models/discord_mention_type.dart';
70 | export 'src/models/discord_message.dart';
71 | export 'src/models/discord_message_activity.dart';
72 | export 'src/models/discord_message_activity_type.dart';
73 | export 'src/models/discord_message_component.dart';
74 | export 'src/models/discord_message_component_type.dart';
75 | export 'src/models/discord_message_flag.dart';
76 | export 'src/models/discord_message_interaction.dart';
77 | export 'src/models/discord_message_interaction_type.dart';
78 | export 'src/models/discord_message_notifications_level.dart';
79 | export 'src/models/discord_message_reference.dart';
80 | export 'src/models/discord_message_type.dart';
81 | export 'src/models/discord_mfa_level.dart';
82 | export 'src/models/discord_nsfw_level.dart';
83 | export 'src/models/discord_optional_audit_entry_info.dart';
84 | export 'src/models/discord_overwrite.dart';
85 | export 'src/models/discord_overwrite_type.dart';
86 | export 'src/models/discord_premium_type.dart';
87 | export 'src/models/discord_presence_update.dart';
88 | export 'src/models/discord_reaction.dart';
89 | export 'src/models/discord_role.dart';
90 | export 'src/models/discord_role_tags.dart';
91 | export 'src/models/discord_snowflake.dart';
92 | export 'src/models/discord_stage_instance.dart';
93 | export 'src/models/discord_stage_privacy_level.dart';
94 | export 'src/models/discord_status.dart';
95 | export 'src/models/discord_sticker.dart';
96 | export 'src/models/discord_sticker_format_type.dart';
97 | export 'src/models/discord_sticker_item.dart';
98 | export 'src/models/discord_sticker_pack.dart';
99 | export 'src/models/discord_sticker_type.dart';
100 | export 'src/models/discord_system_channel_flag.dart';
101 | export 'src/models/discord_team.dart';
102 | export 'src/models/discord_team_member.dart';
103 | export 'src/models/discord_thread_member.dart';
104 | export 'src/models/discord_thread_metadata.dart';
105 | export 'src/models/discord_token.dart';
106 | export 'src/models/discord_token_webhook.dart';
107 | export 'src/models/discord_user.dart';
108 | export 'src/models/discord_user_flag.dart';
109 | export 'src/models/discord_verification_level.dart';
110 | export 'src/models/discord_video_quality_mode.dart';
111 | export 'src/models/discord_voice_region.dart';
112 | export 'src/models/discord_voice_state.dart';
113 | export 'src/models/discord_webhook.dart';
114 | export 'src/models/discord_welcome_screen.dart';
115 | export 'src/models/discord_welcome_screen_channel.dart';
116 | export 'src/providers/discord_dio_provider.dart'; //! TEMPORARY
117 | export 'src/providers/discord_http_client.dart';
118 |
--------------------------------------------------------------------------------
/lib/src/exceptions/discord_api_exceptions.dart:
--------------------------------------------------------------------------------
1 | class DiscordApiException implements Exception {
2 | final String message;
3 |
4 | const DiscordApiException(this.message);
5 |
6 | @override
7 | String toString() => 'DiscordException: $message';
8 | }
9 |
--------------------------------------------------------------------------------
/lib/src/extensions/string_extensions.dart:
--------------------------------------------------------------------------------
1 | extension StringExtension on String {
2 | String capitalize() {
3 | return "${this[0].toUpperCase()}${substring(1).toLowerCase()}";
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/lib/src/models/discord_activity_assets.dart:
--------------------------------------------------------------------------------
1 | class DiscordActivityAssets {
2 | /// see [Activity Asset Image](https://discord.com/developers/docs/topics/gateway#activity-object-activity-asset-image)
3 | ///
4 | /// is not always returned, hence the nullable property
5 | final String? largeImage;
6 |
7 | /// text displayed when hovering over the large image of the activity
8 | ///
9 | /// is not always returned, hence the nullable property
10 | final String? largeText;
11 |
12 | /// see [Activity Asset Image](https://discord.com/developers/docs/topics/gateway#activity-object-activity-asset-image)
13 | ///
14 | /// is not always returned, hence the nullable property
15 | final String? smallImage;
16 |
17 | /// text displayed when hovering over the small image of the activity
18 | ///
19 | /// is not always returned, hence the nullable property
20 | final String? smallText;
21 |
22 | static const largeImageEntry = 'large_image';
23 | static const largeTextEntry = 'large_text';
24 | static const smallImageEntry = 'small_image';
25 | static const smallTextEntry = 'small_text';
26 |
27 | DiscordActivityAssets({
28 | this.largeImage,
29 | this.largeText,
30 | this.smallImage,
31 | this.smallText,
32 | });
33 |
34 | factory DiscordActivityAssets.fromJson(Map json) =>
35 | DiscordActivityAssets(
36 | largeImage: json[largeImageEntry] as String?,
37 | largeText: json[largeTextEntry] as String?,
38 | smallImage: json[smallImageEntry] as String?,
39 | smallText: json[smallTextEntry] as String?,
40 | );
41 | }
42 |
--------------------------------------------------------------------------------
/lib/src/models/discord_activity_button.dart:
--------------------------------------------------------------------------------
1 | class DiscordActivityButton {
2 | /// the text shown on the button (1-32 characters)
3 | final String label;
4 |
5 | /// the url opened when clicking the button (1-512 characters)
6 | final String url;
7 |
8 | static const labelEntry = 'label';
9 | static const urlEntry = 'url';
10 |
11 | DiscordActivityButton({
12 | required this.label,
13 | required this.url,
14 | });
15 |
16 | factory DiscordActivityButton.fromJson(Map json) =>
17 | DiscordActivityButton(
18 | label: json[labelEntry] as String,
19 | url: json[urlEntry] as String,
20 | );
21 | }
22 |
--------------------------------------------------------------------------------
/lib/src/models/discord_activity_flag.dart:
--------------------------------------------------------------------------------
1 | enum DiscordActivityFlag {
2 | /// 1 << 0
3 | instance,
4 |
5 | /// 1 << 1
6 | join,
7 |
8 | /// 1 << 2
9 | spectate,
10 |
11 | /// 1 << 3
12 | joinRequest,
13 |
14 | /// 1 << 4
15 | sync,
16 |
17 | /// 1 << 5
18 | play,
19 |
20 | /// 1 << 6
21 | partyPrivacyFriends,
22 |
23 | /// 1 << 7
24 | partyPrivacyVoiceChannel,
25 |
26 | /// 1 << 8
27 | embedded,
28 | }
29 |
--------------------------------------------------------------------------------
/lib/src/models/discord_activity_party.dart:
--------------------------------------------------------------------------------
1 | class DiscordActivityParty {
2 | /// the id of the party
3 | ///
4 | /// is not always returned, hence the nullable property
5 | final String? id;
6 |
7 | /// used to show the party's current and maximum size
8 | ///
9 | /// is an array of two integers (current_size, max_size)
10 | final List? size;
11 |
12 | static const idEntry = "id";
13 | static const sizeEntry = "size";
14 |
15 | DiscordActivityParty({
16 | this.id,
17 | this.size,
18 | });
19 |
20 | factory DiscordActivityParty.fromJson(Map json) =>
21 | DiscordActivityParty(
22 | id: json[idEntry] as String?,
23 | size: List.from(json[sizeEntry] as List),
24 | );
25 | }
26 |
--------------------------------------------------------------------------------
/lib/src/models/discord_activity_secrets.dart:
--------------------------------------------------------------------------------
1 | class DiscordActivitySecrets {
2 | /// the secret for joining a party
3 | ///
4 | /// is not always returned, hence the nullable property
5 | final String? join;
6 |
7 | /// the secret for spectating a game
8 | ///
9 | /// is not always returned, hence the nullable property
10 | final String? spectate;
11 |
12 | /// the secret for a specific instanced match
13 | ///
14 | /// is not always returned, hence the nullable property
15 | final String? match;
16 |
17 | static const joinEntry = 'join';
18 | static const spectateEntry = 'spectate';
19 | static const matchEntry = 'match';
20 |
21 | DiscordActivitySecrets({
22 | this.join,
23 | this.spectate,
24 | this.match,
25 | });
26 |
27 | factory DiscordActivitySecrets.fromJson(Map json) =>
28 | DiscordActivitySecrets(
29 | join: json[joinEntry] as String?,
30 | spectate: json[spectateEntry] as String?,
31 | match: json[matchEntry] as String?,
32 | );
33 | }
34 |
--------------------------------------------------------------------------------
/lib/src/models/discord_activity_timestamps.dart:
--------------------------------------------------------------------------------
1 | class DiscordActivityTimestamps {
2 | /// unix time (in milliseconds) of when the activity started
3 | ///
4 | /// is not always returned, hence the nullable property
5 | final int? start;
6 |
7 | late final DateTime? _startAsDateTime;
8 |
9 | /// unix time (in milliseconds) of when the activity ends
10 | ///
11 | /// is not always returned, hence the nullable property
12 | final int? end;
13 |
14 | late final DateTime? _endAsDateTime;
15 |
16 | static const startEntry = 'start';
17 | static const endEntry = 'end';
18 |
19 | DiscordActivityTimestamps({
20 | this.start,
21 | this.end,
22 | });
23 |
24 | DateTime? get startAsDateTime {
25 | if (start == null) return null;
26 | return _startAsDateTime ??= DateTime.fromMillisecondsSinceEpoch(start!);
27 | }
28 |
29 | DateTime? get endAsDateTime {
30 | if (end == null) return null;
31 | return _endAsDateTime ??= DateTime.fromMillisecondsSinceEpoch(end!);
32 | }
33 |
34 | factory DiscordActivityTimestamps.fromJson(Map json) =>
35 | DiscordActivityTimestamps(
36 | start: json['start'] as int?,
37 | end: json['end'] as int?,
38 | );
39 | }
40 |
--------------------------------------------------------------------------------
/lib/src/models/discord_activity_type.dart:
--------------------------------------------------------------------------------
1 | /// Enum of Activity Types
2 | ///
3 | /// The streaming type currently only supports Twitch and YouTube.
4 | /// Only `https://twitch.tv/` and `https://www.youtube.com/` urls will work.
5 | enum DiscordActivityType {
6 | /// ID: 0
7 | /// Name: Game
8 | /// Format: Playing {name}
9 | /// Example: "Playing Rocket League"
10 | game,
11 |
12 | /// ID: 1
13 | /// Name: Streaming
14 | /// Format: Streaming {details}
15 | /// Example: "Streaming Rocket League"
16 | streaming,
17 |
18 | /// ID: 2
19 | /// Name: Listening
20 | /// Format: Listening to {name}
21 | /// Example: "Listening to Spotify"
22 | listening,
23 |
24 | /// ID: 3
25 | /// Name: Watching
26 | /// Format: Watching {name}
27 | /// Example: "Watching YouTube Together"
28 | watching,
29 |
30 | /// ID: 4
31 | /// Name: Custom
32 | /// Format: {emoji} {name}
33 | /// Example: ":smiley: I am cool"
34 | custom,
35 |
36 | /// ID: 5
37 | /// Name: Competing
38 | /// Format: Competing in {name}
39 | /// Example: "Competing in Arena World Champions"
40 | competing,
41 | }
42 |
--------------------------------------------------------------------------------
/lib/src/models/discord_allowed_mentions.dart:
--------------------------------------------------------------------------------
1 | import 'discord_mention_type.dart';
2 |
3 | class DiscordAllowedMentions {
4 | /// an array of [allowed mention types](https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mention-types)
5 | /// to parse from the content.
6 | final List parse;
7 |
8 | late final List? _parseAsEnum;
9 |
10 | /// array of role_ids to mention (Max size of 100)
11 | ///
12 | /// Should be converted to DiscordSnowflake if the need arise
13 | final List roles;
14 |
15 | /// array of user_ids to mention (Max size of 100)
16 | ///
17 | /// Should be converted to DiscordSnowflake if the need arise
18 | final List users;
19 |
20 | /// for replies, whether to mention the author of the message being
21 | /// replied to (default false)
22 | final bool repliedUser;
23 |
24 | static const parseEntry = 'parse';
25 | static const rolesEntry = 'roles';
26 | static const usersEntry = 'users';
27 | static const repliedUserEntry = 'replied_user';
28 |
29 | DiscordAllowedMentions({
30 | required this.parse,
31 | required this.roles,
32 | required this.users,
33 | required this.repliedUser,
34 | });
35 |
36 | DiscordMentionType _getFromString(String value) {
37 | switch (value) {
38 | case 'users':
39 | return DiscordMentionType.users;
40 | case 'roles':
41 | return DiscordMentionType.roles;
42 | case 'everyone':
43 | return DiscordMentionType.everyone;
44 | default:
45 | throw ArgumentError('Unknown mention type: $value');
46 | }
47 | }
48 |
49 | List get parseAsEnum =>
50 | _parseAsEnum ??= parse.map((e) => _getFromString(e)).toList();
51 |
52 | factory DiscordAllowedMentions.fromJson(Map json) =>
53 | DiscordAllowedMentions(
54 | parse: List.from(json[parseEntry] as List),
55 | roles: List.from(json[rolesEntry] as List),
56 | users: List.from(json[usersEntry] as List),
57 | repliedUser: json[repliedUserEntry] as bool,
58 | );
59 | }
60 |
--------------------------------------------------------------------------------
/lib/src/models/discord_api_scope.dart:
--------------------------------------------------------------------------------
1 | enum DiscordApiScope {
2 | activitiesRead,
3 | activitiesWrite,
4 | applicationsBuildsRead,
5 | applicationsBuildsUpload,
6 | applicationsCommands,
7 | applicationsCommandsUpdate,
8 | applicationsEntitlements,
9 | applicationsStoreUpdate,
10 | bot,
11 | connections,
12 | email,
13 | gdmJoin,
14 | guilds,
15 | guildsJoin,
16 | guilsMembersRead,
17 | identify,
18 | messagesRead,
19 | rpc,
20 | rpcActivitiesWrite,
21 | rpcNotificationsRead,
22 | rpcVoiceRead,
23 | rpcVoiceWrite,
24 | webhookIncoming,
25 | }
26 |
27 | extension DiscordApiScopeModifier on DiscordApiScope {
28 | String get string {
29 | final RegExp regExp = RegExp('(?<=[a-z])[A-Z]');
30 | return name
31 | .replaceAllMapped(regExp, (match) => '.${match.group(0)}')
32 | .toLowerCase();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/lib/src/models/discord_application_flag.dart:
--------------------------------------------------------------------------------
1 | enum DiscordApplicationFlag {
2 | /// 1 << 12
3 | gatewayPresence,
4 |
5 | /// 1 << 13
6 | gatewayPresenceLimited,
7 |
8 | /// 1 << 14
9 | gatewayGuildMembers,
10 |
11 | /// 1 << 15
12 | gatewayGuildMembersLimited,
13 |
14 | /// 1 << 16
15 | verificationPendingGuildLimit,
16 |
17 | /// 1 << 17
18 | embedded,
19 |
20 | /// 1 << 18
21 | gatewayMessageContent,
22 |
23 | /// 1 << 19
24 | gatewayMessageContentLimited,
25 | }
26 |
27 | void _addFlagAsEnum(
28 | String r,
29 | int index,
30 | DiscordApplicationFlag flag,
31 | List f,
32 | ) {
33 | if (r.length >= index + 1 && r.substring(index, index + 1) == '1') {
34 | f.add(flag);
35 | }
36 | }
37 |
38 | List discordApplicationFlagsAsEnum(int? flags) {
39 | if (flags == null) {
40 | return [];
41 | }
42 | final flagsAsEnum = [];
43 | final radixString =
44 | String.fromCharCodes(flags.toRadixString(2).runes.toList().reversed);
45 | _addFlagAsEnum(
46 | radixString,
47 | 12,
48 | DiscordApplicationFlag.gatewayPresence,
49 | flagsAsEnum,
50 | );
51 | _addFlagAsEnum(
52 | radixString,
53 | 13,
54 | DiscordApplicationFlag.gatewayPresenceLimited,
55 | flagsAsEnum,
56 | );
57 | _addFlagAsEnum(
58 | radixString,
59 | 14,
60 | DiscordApplicationFlag.gatewayGuildMembers,
61 | flagsAsEnum,
62 | );
63 | _addFlagAsEnum(
64 | radixString,
65 | 15,
66 | DiscordApplicationFlag.gatewayGuildMembersLimited,
67 | flagsAsEnum,
68 | );
69 | _addFlagAsEnum(
70 | radixString,
71 | 16,
72 | DiscordApplicationFlag.verificationPendingGuildLimit,
73 | flagsAsEnum,
74 | );
75 | _addFlagAsEnum(
76 | radixString,
77 | 17,
78 | DiscordApplicationFlag.embedded,
79 | flagsAsEnum,
80 | );
81 | _addFlagAsEnum(
82 | radixString,
83 | 18,
84 | DiscordApplicationFlag.gatewayMessageContent,
85 | flagsAsEnum,
86 | );
87 | _addFlagAsEnum(
88 | radixString,
89 | 19,
90 | DiscordApplicationFlag.gatewayMessageContentLimited,
91 | flagsAsEnum,
92 | );
93 | return flagsAsEnum;
94 | }
95 |
--------------------------------------------------------------------------------
/lib/src/models/discord_attachment.dart:
--------------------------------------------------------------------------------
1 | import 'discord_snowflake.dart';
2 |
3 | class DiscordAttachment {
4 | /// attachment id
5 | final DiscordSnowflake id;
6 |
7 | /// name of file attached
8 | final String filename;
9 |
10 | /// description for the file
11 | final String? description;
12 |
13 | /// the attachment's [media type](https://en.wikipedia.org/wiki/Media_type)
14 | final String? contentType;
15 |
16 | /// size of file in bytes
17 | final int size;
18 |
19 | /// source url of file
20 | final String url;
21 |
22 | /// a proxied url of file
23 | final String proxyUrl;
24 |
25 | /// height of file (if image)
26 | final int? height;
27 |
28 | /// width of file (if image)
29 | final int? width;
30 |
31 | /// whether this attachment is ephemeral
32 | final bool? ephemeral;
33 |
34 | static const idEntry = 'id';
35 | static const filenameEntry = 'filename';
36 | static const descriptionEntry = 'description';
37 | static const contentTypeEntry = 'content_type';
38 | static const sizeEntry = 'size';
39 | static const urlEntry = 'url';
40 | static const proxyUrlEntry = 'proxy_url';
41 | static const heightEntry = 'height';
42 | static const widthEntry = 'width';
43 | static const ephemeralEntry = 'ephemeral';
44 |
45 | DiscordAttachment({
46 | required this.id,
47 | required this.filename,
48 | this.description,
49 | this.contentType,
50 | required this.size,
51 | required this.url,
52 | required this.proxyUrl,
53 | this.height,
54 | this.width,
55 | this.ephemeral,
56 | });
57 |
58 | factory DiscordAttachment.fromJson(Map json) =>
59 | DiscordAttachment(
60 | id: DiscordSnowflake(json[idEntry] as String),
61 | filename: json[filenameEntry] as String,
62 | description: json[descriptionEntry] as String?,
63 | contentType: json[contentTypeEntry] as String?,
64 | size: json[sizeEntry] as int,
65 | url: json[urlEntry] as String,
66 | proxyUrl: json[proxyUrlEntry] as String,
67 | height: json[heightEntry] as int?,
68 | width: json[widthEntry] as int?,
69 | ephemeral: json[ephemeralEntry] as bool?,
70 | );
71 | }
72 |
--------------------------------------------------------------------------------
/lib/src/models/discord_audit_log.dart:
--------------------------------------------------------------------------------
1 | import 'discord_audit_log_entry.dart';
2 | import 'discord_channel.dart';
3 | import 'discord_guild_scheduled_event.dart';
4 | import 'discord_integration.dart';
5 | import 'discord_user.dart';
6 | import 'discord_webhook.dart';
7 |
8 | class DiscordAuditLog {
9 | /// list of audit log entries
10 | final List auditLogEntries;
11 |
12 | /// list of guild scheduled events found in the audit log
13 | final List guildScheduledEvents;
14 |
15 | /// list of partial integration objects
16 | final List integrations;
17 |
18 | /// list of threads found in the audit log
19 | ///
20 | /// * Threads referenced in THREAD_CREATE and THREAD_UPDATE
21 | /// events are included in the threads map, since archived
22 | /// threads might not be kept in memory by clients.
23 | final List threads;
24 |
25 | /// list of users found in the audit log
26 | final List users;
27 |
28 | /// list of webhooks found in the audit log
29 | final List webhooks;
30 |
31 | static const auditLogEntriesEntry = 'audit_log_entries';
32 | static const guildScheduledEventsEntry = 'guild_scheduled_events';
33 | static const integrationsEntry = 'integrations';
34 | static const threadsEntry = 'threads';
35 | static const usersEntry = 'users';
36 | static const webhooksEntry = 'webhooks';
37 |
38 | DiscordAuditLog({
39 | required this.auditLogEntries,
40 | required this.guildScheduledEvents,
41 | required this.integrations,
42 | required this.threads,
43 | required this.users,
44 | required this.webhooks,
45 | });
46 |
47 | factory DiscordAuditLog.fromJson(Map json) =>
48 | DiscordAuditLog(
49 | auditLogEntries: List.from(
50 | (json[auditLogEntriesEntry] as List