Add ping command

This commit is contained in:
Tulir Asokan
2023-03-01 22:05:57 +02:00
parent 0403a705b6
commit febb28882e

View File

@@ -55,6 +55,7 @@ func (br *DiscordBridge) RegisterCommands() {
cmdLoginToken,
cmdLoginQR,
cmdLogout,
cmdPing,
cmdReconnect,
cmdDisconnect,
cmdSetRelay,
@@ -284,6 +285,29 @@ func fnLogout(ce *WrappedCommandEvent) {
}
}
var cmdPing = &commands.FullHandler{
Func: wrapCommand(fnPing),
Name: "ping",
Help: commands.HelpMeta{
Section: commands.HelpSectionAuth,
Description: "Check your connection to Discord",
},
}
func fnPing(ce *WrappedCommandEvent) {
if ce.User.Session == nil {
if ce.User.DiscordToken == "" {
ce.Reply("You're not logged in")
} else {
ce.Reply("You have a Discord token stored, but are not connected for some reason 🤔")
}
} else if ce.User.wasDisconnected {
ce.Reply("You're logged in, but the Discord connection seems to be dead 💥")
} else {
ce.Reply("You're logged in as %s#%s (`%s`)", ce.User.Session.State.User.Username, ce.User.Session.State.User.Discriminator, ce.User.DiscordID)
}
}
var cmdDisconnect = &commands.FullHandler{
Func: wrapCommand(fnDisconnect),
Name: "disconnect",