Comments (4)
Can you show me how I can reproduce the issue?
from ken.
Sure, here's some code:
func (*ImageboardCommand) Run(ctx ken.Context) (err error) {
if err = ctx.Defer(); err != nil {
return
}
bd := AssertArgument(ctx)
message := ctx.FollowUpEmbed(bd.Modal())
message.AddComponents(func(cb *ken.ComponentBuilder) {
cb.AddActionsRow(func(b ken.ComponentAssembler) {
b.Add(discordgo.Button{
CustomID: fmt.Sprint(rand.Intn(3000)),
Style: discordgo.PrimaryButton,
Label: "⏭️",
}, func(ctx ken.ComponentContext) bool {
bd.Next()
message.Send().EditEmbed(bd.Modal())
return true
})
})
})
message.Send()
return err
}
from ken.
Yeah, there are definitely some Issues with your code.
First of all, ctx.FollowUpEmbed
does now return a *FollowUpMessageBuilder
which can be turned into a *FollowUpMessage
by using the Send
method on it.
So, the second call to Send
in your component handler does not make a lot of sense, because the message has already been sent. You need to capture the resulting *FollowUpMessage
and perform EditEmbed
on that.
Something like this should work.
func (*ImageboardCommand) Run(ctx ken.Context) (err error) {
if err = ctx.Defer(); err != nil {
return
}
var fum *ken.FollowUpMessage
bd := AssertArgument(ctx)
message := ctx.FollowUpEmbed(bd.Modal())
message.AddComponents(func(cb *ken.ComponentBuilder) {
cb.AddActionsRow(func(b ken.ComponentAssembler) {
b.Add(discordgo.Button{
CustomID: fmt.Sprint(rand.Intn(3000)),
Style: discordgo.PrimaryButton,
Label: "⏭️",
}, func(ctx ken.ComponentContext) bool {
bd.Next()
fum.EditEmbed(bd.Modal())
return true
})
})
})
fum = message.Send()
return fum.Error
}
Also, because Send
does not directly return an error, the errors in the call chain are captured in the FollowUpMessage
's property Error
, which should be checked after performing actions like Send
or EditEmbed
. I know that this approach is not very easy to see through but I am working on it to make the API more understandable and usable. 😄
from ken.
Ah, alright thanks for the advice!
from ken.
Related Issues (12)
- Add support for Modals
- add new guild scope to slash commands
- Add message components on message creation
- Add support for sub-command groups
- Use ken with discordgo.InteractionCreate HOT 8
- Delete RespondEmbed? HOT 1
- Atuocomplete Bindings
- Updating Application Commands instead of deleting/creating them
- Provide endpoint to get all registered commands with their details
- FollowUp Messages sometimes lead to `interaction failed` error
- Message Component Bindings
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ken.