No button emoji

This commit is contained in:
rxdn 2021-08-30 15:11:27 +01:00
parent 2b355f42eb
commit d90e6ac262
4 changed files with 32 additions and 20 deletions

View File

@ -62,7 +62,6 @@ func MultiPanelCreate(ctx *gin.Context) {
return
}
messageId, err := data.sendEmbed(&botContext, premiumTier > premium.None, panels)
if err != nil {
var unwrapped request.RestError
@ -212,13 +211,18 @@ func (d *multiPanelCreateData) sendEmbed(ctx *botcontext.BotContext, isPremium b
buttons := make([]component.Component, len(panels))
for i, panel := range panels {
var buttonEmoji *emoji.Emoji
if panel.ReactionEmote != "" {
buttonEmoji = &emoji.Emoji{
Name: panel.ReactionEmote,
}
}
buttons[i] = component.BuildButton(component.Button{
Label: panel.Title,
CustomId: panel.CustomId,
Style: component.ButtonStyle(panel.ButtonStyle),
Emoji: emoji.Emoji{
Name: panel.ReactionEmote,
},
Emoji: buttonEmoji,
})
}
@ -240,7 +244,7 @@ func (d *multiPanelCreateData) sendEmbed(ctx *botcontext.BotContext, isPremium b
}
data := rest.CreateMessageData{
Embed: e,
Embeds: []*embed.Embed{e},
Components: rows,
}

View File

@ -250,14 +250,16 @@ func (p *panelBody) doValidations(ctx *gin.Context, guildId uint64) bool {
return false
}
if p.Emote != "" { // Allow no emoji
_, validEmoji := p.getEmoji()
if !validEmoji {
ctx.AbortWithStatusJSON(400, gin.H{
"success": false,
"error": "Invalid emoji. Simply use the emoji's name from Discord.",
"error": "Invalid emoji. Simply use the emoji itself, or the emoji's name from Discord.",
})
return false
}
}
if !p.verifyWelcomeMessage() {
ctx.AbortWithStatusJSON(400, gin.H{
@ -307,6 +309,7 @@ func (p *panelBody) verifyContent() bool {
}
func (p *panelBody) getEmoji() (emoji string, ok bool) {
p.Emote = strings.TrimSpace(p.Emote)
p.Emote = strings.Replace(p.Emote, ":", "", -1)
emoji, ok = utils.GetEmoji(p.Emote)
@ -377,19 +380,24 @@ func (p *panelBody) sendEmbed(ctx *botcontext.BotContext, title, customId, emote
if !isPremium {
// TODO: Don't harcode
e.SetFooter("Powered by ticketsbot.net", "https://cdn.discordapp.com/avatars/508391840525975553/ac2647ffd4025009e2aa852f719a8027.png?size=256")
e.SetFooter("Powered by ticketsbot.net", "https://ticketsbot.net/assets/img/logo.png")
}
var buttonEmoji *emoji.Emoji
if emote != "" {
buttonEmoji = &emoji.Emoji{
Name: emote,
}
}
data := rest.CreateMessageData{
Embed: e,
Embeds: []*embed.Embed{e},
Components: []component.Component{
component.BuildActionRow(component.BuildButton(component.Button{
Label: title,
CustomId: customId,
Style: buttonStyle,
Emoji: emoji.Emoji{
Name: emote,
},
Emoji: buttonEmoji,
Url: nil,
Disabled: false,
})),

View File

@ -1,7 +1,7 @@
<div class:col-1={col1} class:col-2={col2} class:col-3={col3} class:col-4={col4}>
<label for="input" class="form-label">{label}</label>
<div class="wrapper">
<input id="input" class="form-input" readonly placeholder="{placeholder}" disabled="{disabled}" bind:value={value}>
<input id="input" class="form-input" placeholder="{placeholder}" disabled="{disabled}" bind:value={value}>
{#if !disabled}
<EmojiSelector on:emoji={onUpdate}/>
{/if}

4
go.mod
View File

@ -7,7 +7,7 @@ require (
github.com/TicketsBot/archiverclient v0.0.0-20210220155137-a562b2f1bbbb
github.com/TicketsBot/common v0.0.0-20210727134627-35eb7ed03a44
github.com/TicketsBot/database v0.0.0-20210816195201-90c765ca95c8
github.com/TicketsBot/worker v0.0.0-20210727130432-3df3cd1246a3
github.com/TicketsBot/worker v0.0.0-20210830140323-d24e405daad7
github.com/apex/log v1.1.2
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff // indirect
github.com/gin-contrib/static v0.0.0-20191128031702-f81c604d8ac2
@ -20,7 +20,7 @@ require (
github.com/jackc/pgx/v4 v4.7.1
github.com/pasztorpisti/qs v0.0.0-20171216220353-8d6c33ee906c
github.com/pkg/errors v0.9.1
github.com/rxdn/gdl v0.0.0-20210725114558-8c3e5dcf3642
github.com/rxdn/gdl v0.0.0-20210830140125-02253feef960
github.com/sirupsen/logrus v1.5.0
github.com/ulule/limiter/v3 v3.5.0
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a