-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add GuildVoiceChannelEffectSend * Add Soundboard * add event to ListenerAdapter * add soundboard sound events * rename file * rename interface * add sound fetching * add check for gateway * add docs for GuildVoiceChannelEffectSend * rename SoundboardAnimationType to SoundboardEffectAnimationType * bruh * change param to varargs * remove pointless else * add CDNEndpoint.Path() * shorten impl name * add audit log events * updates * add caches * remove SoundOverridePath * updates * remove UserID from SoundboardSound * updates discord/discord-api-docs@8b05cc6 * add URL() * add required intent + fix docs * SoundboardEffectAnimationType -> VoiceChannelEffectAnimationType * oh man * Revert "oh man" This reverts commit 7957f48. * change SoundID type to int64 with ,string * add event umarshaler * damn this shit is broken * add GuildFeatureMoreSoundboard discord/discord-api-docs@5a13333 * add missing cache getter * add request func to client interface * fix endpoint method * Update discord/soundboard.go Co-authored-by: Toπ <[email protected]> * Apply suggestions from code review Co-authored-by: Toπ <[email protected]> --------- Co-authored-by: mlnrDev <[email protected]> Co-authored-by: Toπ <[email protected]>
- Loading branch information
1 parent
bb89022
commit 03e9ee0
Showing
24 changed files
with
550 additions
and
50 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
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,59 @@ | ||
package discord | ||
|
||
import ( | ||
"encoding/base64" | ||
"fmt" | ||
"io" | ||
|
||
"github.com/disgoorg/json" | ||
) | ||
|
||
type SoundType string | ||
|
||
const ( | ||
SoundTypeMP3 SoundType = "audio/mpeg" | ||
SoundTypeOGG SoundType = "audio/ogg" | ||
SoundTypeWAV SoundType = "audio/wav" | ||
SoundTypeUnknown = SoundTypeMP3 | ||
) | ||
|
||
func (t SoundType) MIME() string { | ||
return string(t) | ||
} | ||
|
||
func (t SoundType) Header() string { | ||
return "data:" + string(t) + ";base64" | ||
} | ||
|
||
var _ json.Marshaler = (*Sound)(nil) | ||
var _ fmt.Stringer = (*Sound)(nil) | ||
|
||
func NewSound(soundType SoundType, reader io.Reader) (*Sound, error) { | ||
data, err := io.ReadAll(reader) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return NewSoundRaw(soundType, data), nil | ||
} | ||
|
||
func NewSoundRaw(soundType SoundType, src []byte) *Sound { | ||
data := make([]byte, base64.StdEncoding.EncodedLen(len(src))) | ||
base64.StdEncoding.Encode(data, src) | ||
return &Sound{Type: soundType, Data: data} | ||
} | ||
|
||
type Sound struct { | ||
Type SoundType | ||
Data []byte | ||
} | ||
|
||
func (s Sound) MarshalJSON() ([]byte, error) { | ||
return json.Marshal(s.String()) | ||
} | ||
|
||
func (s Sound) String() string { | ||
if len(s.Data) == 0 { | ||
return "" | ||
} | ||
return s.Type.Header() + "," + string(s.Data) | ||
} |
Oops, something went wrong.