-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
123 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package faq | ||
|
||
import ( | ||
"github.com/bwmarrin/discordgo" | ||
"github.com/cake4everyone/cake4everybot/data/lang" | ||
"github.com/cake4everyone/cake4everybot/util" | ||
) | ||
|
||
// The Chat (slash) command of the faq package. | ||
type Chat struct { | ||
faqBase | ||
ID string | ||
} | ||
|
||
const ( | ||
// Prefix for translation key, i.e.: | ||
// key := tp+"base" // => faq | ||
tp = "discord.command.faq." | ||
) | ||
|
||
// AppCmd (ApplicationCommand) returns the definition of the chat command | ||
func (cmd Chat) AppCmd() *discordgo.ApplicationCommand { | ||
return &discordgo.ApplicationCommand{ | ||
Name: lang.GetDefault(tp + "base"), | ||
NameLocalizations: util.TranslateLocalization(tp + "base"), | ||
Description: lang.GetDefault(tp + "base.description"), | ||
DescriptionLocalizations: util.TranslateLocalization(tp + "base.description"), | ||
} | ||
} | ||
|
||
// Handle handles the functionality of a command | ||
func (cmd Chat) Handle(s *discordgo.Session, i *discordgo.InteractionCreate) { | ||
cmd.InteractionUtil = util.InteractionUtil{Session: s, Interaction: i} | ||
cmd.member = i.Member | ||
cmd.user = i.User | ||
if i.Member != nil { | ||
cmd.user = i.Member.User | ||
} else if i.User != nil { | ||
cmd.member = &discordgo.Member{User: i.User} | ||
} | ||
} | ||
|
||
// SetID sets the registered command ID for internal uses after uploading to discord | ||
func (cmd *Chat) SetID(id string) { | ||
cmd.ID = id | ||
} | ||
|
||
// GetID gets the registered command ID | ||
func (cmd Chat) GetID() string { | ||
return cmd.ID | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package faq | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/bwmarrin/discordgo" | ||
"github.com/cake4everyone/cake4everybot/util" | ||
) | ||
|
||
// The Component of the faq package. | ||
type Component struct { | ||
faqBase | ||
data discordgo.MessageComponentInteractionData | ||
} | ||
|
||
// Handle handles the functionality of a component. | ||
func (c Component) Handle(s *discordgo.Session, i *discordgo.InteractionCreate) { | ||
c.InteractionUtil = util.InteractionUtil{Session: s, Interaction: i} | ||
c.member = i.Member | ||
c.user = i.User | ||
if i.Member != nil { | ||
c.user = i.Member.User | ||
} else if i.User != nil { | ||
c.member = &discordgo.Member{User: i.User} | ||
} | ||
//lint:ignore SA4005 currently not used but will be when implementing the component | ||
c.data = i.MessageComponentData() | ||
|
||
ids := strings.Split(c.data.CustomID, ".") | ||
// pop the first level identifier | ||
util.ShiftL(ids) | ||
|
||
switch util.ShiftL(ids) { | ||
default: | ||
log.Printf("Unknown component interaction ID: %s", c.data.CustomID) | ||
} | ||
|
||
} | ||
|
||
// ID returns the custom ID of the modal to identify the module | ||
func (c Component) ID() string { | ||
return "faq" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package faq | ||
|
||
import ( | ||
"github.com/bwmarrin/discordgo" | ||
"github.com/cake4everyone/cake4everybot/logger" | ||
"github.com/cake4everyone/cake4everybot/util" | ||
) | ||
|
||
var log = logger.New("FAQ") | ||
|
||
type faqBase struct { | ||
util.InteractionUtil | ||
member *discordgo.Member | ||
user *discordgo.User | ||
} |