Add ping command
This commit is contained in:
24
commands.go
24
commands.go
@@ -55,6 +55,7 @@ func (br *DiscordBridge) RegisterCommands() {
|
|||||||
cmdLoginToken,
|
cmdLoginToken,
|
||||||
cmdLoginQR,
|
cmdLoginQR,
|
||||||
cmdLogout,
|
cmdLogout,
|
||||||
|
cmdPing,
|
||||||
cmdReconnect,
|
cmdReconnect,
|
||||||
cmdDisconnect,
|
cmdDisconnect,
|
||||||
cmdSetRelay,
|
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{
|
var cmdDisconnect = &commands.FullHandler{
|
||||||
Func: wrapCommand(fnDisconnect),
|
Func: wrapCommand(fnDisconnect),
|
||||||
Name: "disconnect",
|
Name: "disconnect",
|
||||||
|
|||||||
Reference in New Issue
Block a user