mirror of
https://github.com/bwmarrin/discordgo.git
synced 2025-12-23 23:17:45 -05:00
feat: add UpdateCustomStatus
Add Session.UpdateCustomStatus, which allows to set and reset the custom status of a bot.
This commit is contained in:
20
wsapi.go
20
wsapi.go
@@ -389,6 +389,26 @@ func (s *Session) UpdateListeningStatus(name string) (err error) {
|
||||
return s.UpdateStatusComplex(*newUpdateStatusData(0, ActivityTypeListening, name, ""))
|
||||
}
|
||||
|
||||
// UpdateCustomStatus is used to update the user's custom status.
|
||||
// If state!="" then set the custom status.
|
||||
// Else, set user to active and remove the custom status.
|
||||
func (s *Session) UpdateCustomStatus(state string) (err error) {
|
||||
data := UpdateStatusData{
|
||||
Status: "online",
|
||||
}
|
||||
|
||||
if state != "" {
|
||||
// Discord requires a non-empty activity name, therefore we provide "Custom Status" as a placeholder.
|
||||
data.Activities = []*Activity{{
|
||||
Name: "Custom Status",
|
||||
Type: ActivityTypeCustom,
|
||||
State: state,
|
||||
}}
|
||||
}
|
||||
|
||||
return s.UpdateStatusComplex(data)
|
||||
}
|
||||
|
||||
// UpdateStatusComplex allows for sending the raw status update data untouched by discordgo.
|
||||
func (s *Session) UpdateStatusComplex(usd UpdateStatusData) (err error) {
|
||||
// The comment does say "untouched by discordgo", but we might need to lie a bit here.
|
||||
|
||||
Reference in New Issue
Block a user