Skip to content

Commit

Permalink
udpate changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
zekro committed Aug 31, 2022
1 parent 0b65cd4 commit 0dbc8d1
Showing 1 changed file with 50 additions and 10 deletions.
60 changes: 50 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,58 @@
[VERSION]

## Changes
**Warning:** This update of ken introduces a lot of API changes. Please update carefully.

- Fix a bug where the wrapped handler would not be registered in the build wrapper.
- The `ComponentHandlerFunc` now returns a boolean to indicate success of execution.
- The `Ken` instance now has a method `Session` which returns the wrapped Discordgo `Session`
instance.
- The `Build` method of the `ComponentBuilder` now also returns a function to remove components
from the message as well as unregister the handlers.
- The `Unregister` method of the `ComponentHandler` now can take one or more `customId`s to
be unregistered at once.
## Modals [#10]

You can now open modals in the component handler function. The `ComponentContext` now has a
method `OpenModal` which can be used to open a modal in Discord on interaction with the
message component.

```go
// ComponentContext gives access to the underlying
// MessageComponentInteractionData and gives the
// ability to open a Modal afterwards.
type ComponentContext interface {
ContextResponder

// GetData returns the underlying
// MessageComponentInteractionData.
GetData() discordgo.MessageComponentInteractionData

// OpenModal opens a new modal with the given
// title, content and components built with the
// passed build function. A channel is returned
// which will receive a ModalContext when the user
// has interacted with the modal.
OpenModal(
title string,
content string,
build func(b ComponentAssembler),
) (<-chan ModalContext, error)
}
```

Please take a look at the [**modals example**](examples/modals) to see further details on
how to use modals with ken.

## Breaking API Changes

A lot of breaking changes have been introduced to use more interfaces instead of struct
instances which allows better testability using mocks.

The `Run` method of the `Command` interface now is getting passed a `Context` interface instead
of a reference to an instance of `Ctx`. This also means, if you are directly accessing `Session`
or `Event` for example from the `Ctx` instance, you need to change it to accessing these via the
available getter methods (`GetSession` or `GetEvent` for example).

The `SubCommandHandler` now also passes an interface `SubCommandContext` to
the `Run` instead of a reference to an instance of `SubCommandCtx`.

The access to `CtxResponder`, `SubCommandCtx`, `ComponentCtx` and `ModalCtx` are now private
for a cleaner API.

## Update

```
go get -v -u github.com/zekrotja/ken@[VERSION]
```
```

0 comments on commit 0dbc8d1

Please sign in to comment.