Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Bot support #18

Merged
merged 59 commits into from May 10, 2023
Merged

feat: Bot support #18

merged 59 commits into from May 10, 2023

Conversation

cryptoAlgorithm
Copy link
Member

@cryptoAlgorithm cryptoAlgorithm commented Nov 23, 2022

Continuation issue: #26 - Bucket list has been moved to an issue for continued tracking after merger of this PR

This PR aims to bring 1st-class bot support to DiscordKit. The checkboxes below outlines what's completed and what's still in the pipeline. The list, as is the bot API, subject to change at any time since this is under intense development and certain parts of the API are still yet to be decided.

Bucket List

  • Bot gateway identification with intents support
  • Correct user agent, properties and REST authentication
  • Sending basic messages
  • Event dispatching with NotificationCenter for message
    create and ready events
  • Application command registration with a resultBuilder - supported application command types:
    • chatInput - Slash commands
    • user - Actions that appear in context menu of users
    • message - Actions that appear in context menu of messages
  • Adding options to commands in the resultBuilder - supported types:
    • subCommand - A "sub-command" with no options
    • subCommandGroup - A group for nesting other options
    • string - An option accepting a String value
    • integer - An option accepting an Int value
    • boolean - An option accepting a Bool value
    • user - An option accepting a user as its value
    • channel - An option accepting a channel as its value
    • role - An option accepting a role as its value
    • mentionable - An option accepting a @mention as its value
    • number - An option accepting a Double value
    • attachment - An option accepting a file attachment as its value
  • Message components - supported types:
    • Button
    • Action row
    • Select Menu
    • Text Input
  • Handling interactions with a closure, allowing responses
  • Support more types of interaction responses
    • Plain content responses
    • Ephemeral responses
    • Deferred responses
    • Embeds
      • Construct fields with a resultBuilder

Guide

WIP beginner-friendly guide for building a bot with DiscordKit is available!

someday we’ll have full bot and linux support…
@cryptoAlgorithm cryptoAlgorithm marked this pull request as draft November 23, 2022 05:59
@cryptoAlgorithm cryptoAlgorithm changed the title feat (bot): initial bot support feat: Bot support Nov 23, 2022
cryptoAlgorithm and others added 16 commits November 24, 2022 19:05
swiftlint on actions seems to have a different ruleset than when running locally
…values

cleans up a lot of handling code, and fixes ready event handling for bots too!

This is a breaking change and will break even more code in Swiftcord, but fixing that’s a chore for another day.
* patch (logging): add swift-log package

* feat (logging): fully migrate RobustWebSocket to swift log

also used structured/semantic logging

* feat (logging): fully migrate away from OSLog to swift-log
no idea why it was logging the stats at the warning level
user settings update event was also removed as it is depreciated by Discord and no longer sent in the ready object
hopefully this will increase action speed?
patch (robustWebSocket)!: use config struct to get intents
BREAKING CHANGE: rest api methods now return a result or throw (if applicable) instead of an optional
didnt catch this problem as Xcode literally doesn’t care about problems in unused modules
@pardeike
Copy link

pardeike commented Dec 3, 2022

Can you summarise the current progress on this? I am willing to help/contribute but it would be nice to know where you are right now.

this also facilitates easier retrieval of nested options’ values
* feat (command): allow retrieving values of nested options
this ensures there are no erroneous commands left over and only requires one call

feat (command): add bulk command overwrite endpoints
…nment

patch (client): make rest handler non optional and set/remove the token instead
this is in line with discord.js’ behaviour
@cryptoAlgorithm
Copy link
Member Author

I've written a beginner-friendly guide for building a bot with DiscordKit on GitBook! It's still a WIP though, and incomplete.

cryptoAlgorithm and others added 10 commits December 16, 2022 17:27
this removes ambiguity in the case where multiple commands of the same name but different type exist
doesn’t appear to have any breaking changes from api v9
feat (interaction): support embed replies
Certain info was extremely outdated after much neglect
also removed LoC badge that stopped working again
Please note that only repos under the SwiftcordApp org are whitelisted. This instance is not designed to be a public instance to prevent misuse.
* 🏷️ feat: add possibly every single endpoints

* 💡 fix: update comments for docc

* 🏷️ fix: some apis don't have body

* lint: fix some linting violations with swiftlint

Co-authored-by: cryptoAlgorithm <cryptoalgro@gmail.com>
@cryptoAlgorithm
Copy link
Member Author

This should be merged soon, i don't know why it wasn't done earlier...

@cryptoAlgorithm cryptoAlgorithm merged commit 1d7e872 into main May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants