disgoorg / disgo Goto Github PK
View Code? Open in Web Editor NEWA modular Golang Discord API Wrapper
License: Apache License 2.0
A modular Golang Discord API Wrapper
License: Apache License 2.0
After updating to Go 1.18 and to disgo v0.8.3, I began getting nil pointer dereferences upon startup, after the ready
event was fired. They only happened when the Guild
intent was declared in gateway intents. I thought it was only an issue with my current project, so I copied and pasted the "Ping-pong" example from the README (with a minor change at the bottom, where ChannelServices()
was renamed to Channels()
), and got the exact same error.
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x808db4]
goroutine 68 [running]:
github.com/disgoorg/disgo/gateway/handlers.(*gatewayHandlerGuildCreate).HandleGatewayEvent(0x4000345cc0?, {0xb9a8b0?, 0x400001a0c0}, 0x3, {0x951a00?, 0x4000312c80})
/go/pkg/mod/github.com/disgoorg/[email protected]/gateway/handlers/guild_create_handler.go:90 +0x614
github.com/disgoorg/disgo/bot.(*eventManagerImpl).HandleGatewayEvent(0x40004267d0, {0x40006d9610, 0xc}, 0xc?, {0xb8a820, 0x4000737260})
/go/pkg/mod/github.com/disgoorg/[email protected]/bot/event_manager.go:81 +0x128
github.com/disgoorg/disgo/gateway/handlers.DefaultGatewayEventHandler.func1({0x40006d9610, 0xc}, 0x10670?, {0xb8a820, 0x4000737260})
/go/pkg/mod/github.com/disgoorg/[email protected]/gateway/handlers/all_handlers.go:25 +0xa0
github.com/disgoorg/disgo/gateway.(*gatewayImpl).listen(0x40003457c0)
/go/pkg/mod/github.com/disgoorg/[email protected]/gateway/gateway_impl.go:353 +0x750
created by github.com/disgoorg/disgo/gateway.(*gatewayImpl).Open
/go/pkg/mod/github.com/disgoorg/[email protected]/gateway/gateway_impl.go:109 +0x4f0
I am running on an M1 MacBook, but I tested the README example in an Alpine Docker container and got the same result.
I want to keep track of members count of specific voice channel in my app without using session id. How can i achieve that? The problem is that in Voice Leave event data "channel id" is always nil. Doesn't Discord provide id of channel from which user left?
Update go to 1.21
once it's out & replace github.com/disgoorg/log
with slog
Describe the bug
go-csync, introduced in commit 6c253fa, does not have an open source license. This means that by default, it is fully copyrighted, and cannot be used in open source code.
I filed sasha-s/go-csync#4 to maybe get it open sourced, but this is not guaranteed to happen, and in any case, the version currently used is not open source.
Error
The error which gets logged if there is any:
This package contains unlicensed code, which by default is copyrighted to the original author. You may not use these dependencies without first obtaining a license.
(from FOSSA).
To Reproduce
N/A
Expected behavior
Open source projects can only depend on open source code.
Screenshots
N/A
Disgo Version(please complete the following information):
Additional context
Public repositories are not automatically open source.
Hello, I'm wondering if rate limiting is automatically handled when sending web hooks? For example, I want to send 100 web hooks, will disgo automatically delay so that each web hook is sent?
This may be caused by the guild being uncached, due to sweeping, disabled cache policy etc.
After testing I found that rateLimiterImpl.doCleanup
will delete expired buckets.
Webhook limits 30 requests per minute. It will cause high concurrency. Because b.mu.CLock
is locked. However, the deletion of expired buckets causes the previous request UnlockBucket
to fail. Subsequent requests will be deadlocked.
Forwarded from discord
Some sort of method that allows user to register a fallback handler on the router
This could be useful for logging unhandled request and spotting potentially missed things
not sure if it make sense to consider wildcards or just fallback for unhandled routes
the only way i can see wildcards being used is on component's custom ids(even so i dont know if it truly make sense)
Describe the bug
Components inside the handler dont work inside a route.
To Reproduce
Steps to reproduce the behavior:
Use handler and put a component inside a route
Expected behavior
The handler should manage correctly the handler
Disgo Version(please complete the following information):
Describe the bug
I'm seeing this error whenever calling CreateGlobalCommand and the command never seems to be created
Error
2024/06/05 02:18:44 ERROR error unmarshalling response body name=rest_client err="json: cannot unmarshal object into Go value of type discord.ApplicationCommand" endpoint=/applications/820545156070899722/commands code="200 OK" body="{\"id\":\"1247793387591962644\",\"application_id\":\"820545156070899722\",\"version\":\"1247793387591962645\",\"default_member_permissions\":null,\"type\":1,\"name\":\"lfd\",\"name_localizations\":null,\"description\":\"get the looking for duel role\",\"description_localizations\":null,\"dm_permission\":true,\"contexts\":null,\"integration_types\":[0],\"nsfw\":false}\n"
panic: error unmarshalling response body: json: cannot unmarshal object into Go value of type discord.ApplicationCommand
To Reproduce
Steps to reproduce the behavior:
...
cmd := discord.SlashCommandCreate {
Name: "lfd",
Description: "get the looking for duel role",
}
_, err = client.Rest().CreateGlobalCommand(client.ApplicationID(), cmd)
if err != nil {
panic(err)
}
...
Expected behavior
The command should be created and an struct representing the command should be parsed out of the response body
Disgo Version(please complete the following information):
When I run (rest.Channels).GetWebhooks I get the error below
error unmarshalling response body: json: cannot unmarshal object into Go value of type discord.Webhook
I think it's probably because it's passing []discord.Webhook to rsBody in the (rest.Client).Do function.
So the same thing happens with (rest.Guilds).GetAllWebhooks
So what this means I. English
Originally posted by @Coolmandre in #350 (comment)
Describe the bug
A clear and concise description of what the bug is.
Error
The error which gets logged if there is any:
import "github.com/disgoorg/disgo/webhook"
client := webhook.NewClient(snowflake.ID("webhookID"), "webhookToken")
message, err := client.CreateEmbeds(discord.NewEmbedBuilder().
SetDescription("hello world!").
Build(),
)
Expected behavior
Send embeded webhook
Additional context
undefined: webhook.Newclient
if my program restarts immediately after reaching the text per minute webhook limit, will disgoorg automatically wait after the restart to send the messages or will it just throw a 429 error?
If it throws 429 error, what's the workaround?
Probably a func that can wait for a specified time between requests?
Describe the bug
Fix this bullshit with discord.NewEmbedBuilder().
discord.NewEmbedBuilder (value of type func() *discord.EmbedBuilder) is not a type
Describe the bug
We're experiencing a problem with disgo staying connected to the gateway for long durations (many weeks). We have gateway.WithAutoReconnect(true)
, but still occasionally log in to discord and see the bot offline, even though the process is still running ok, and other parts of the process are working fine. I'm not exactly certain at which point it goes offline, but looking at the logs for the night, these errors were logged:
Error
The error which gets logged if there is any:
time="2023-09-06T00:52:13Z" level=info msg="Received event" Duration="301.324µs" Event="On Member Joined Voice" Guild=...
2023/09/06 00:52:13 ERROR error while parsing voice gateway event. error: json: cannot unmarshal object into Go value of type voice.GatewayMessageDataUnknown
2023/09/06 00:52:13 ERROR error while parsing voice gateway event. error: json: cannot unmarshal object into Go value of type voice.GatewayMessageDataUnknown
2023/09/06 00:52:13 ERROR error while parsing voice gateway event. error: json: cannot unmarshal object into Go value of type voice.GatewayMessageDataUnknown
2023/09/06 00:52:13 ERROR error while parsing voice gateway event. error: json: cannot unmarshal object into Go value of type voice.GatewayMessageDataUnknown
2023/09/06 00:52:13 ERROR error while parsing voice gateway event. error: json: cannot unmarshal object into Go value of type voice.GatewayMessageDataUnknown
2023/09/06 00:52:13 ERROR error while parsing voice gateway event. error: json: cannot unmarshal object into Go value of type voice.GatewayMessageDataUnknown
2023/09/06 00:52:13 ERROR error while parsing voice gateway event. error: json: cannot unmarshal object into Go value of type voice.GatewayMessageDataUnknown
2023/09/06 00:52:13 ERROR error while parsing voice gateway event. error: json: cannot unmarshal object into Go value of type voice.GatewayMessageDataUnknown
2023/09/06 00:52:13 ERROR error while parsing voice gateway event. error: json: cannot unmarshal object into Go value of type voice.GatewayMessageDataUnknown
2023/09/06 00:52:13 ERROR error while parsing voice gateway event. error: json: cannot unmarshal object into Go value of type voice.GatewayMessageDataUnknown
To Reproduce
Steps to reproduce the behavior:
Run the bot for a very long time
Expected behavior
Not disconnect from gateway
Screenshots
If applicable, add screenshots to help explain your problem.
Disgo Version(please complete the following information):
Additional context
Add any other context about the problem here.
prob in a another repo I guess
https://pkg.go.dev/github.com/prometheus/client_golang/prometheus
Describe the bug
Guild ID is nil on slash-command interactions, even if the command is ran in a guild.
Error
The error which gets logged if there is any:
ERROR recovered from panic in event listener: runtime error: invalid memory address or nil pointer dereference
stack: goroutine 170 [running]
To Reproduce
Steps to reproduce the behavior:
func commandListener(event *events.ApplicationCommandInteractionCreate) {
data := event.SlashCommandInteractionData()
if data.CommandName() == "pull-members" {
fmt.Println(data.GuildID().String())
...
Expected behavior
It's expected to not be nil when the command is ran in a guild.
Disgo Version(please complete the following information):
Very latest (just installed package)
Describe the bug
404 not found error
Error
The error which gets logged if there is any:
ERROR error sending message: Status: 404 Not Found, Body: {"message": "404: Not Found", "code": 0}
To Reproduce
Steps to reproduce the behavior:
if _, err := clientDiscord.CreateMessage(discord.NewWebhookMessageCreateBuilder().
SetContentf("test 1").
Build(),
// delay each request by 2 seconds
rest.WithDelay(2*time.Second),
); err != nil {
log.Errorf("error sending message: %s", err)
}
Disgo Version(please complete the following information):
Recently i got very confusing bug with voice manager opening connection to voice gateway (maybe it's on my side but i have no clue what's can be wrong).
In my app i have a struct with voice manager which i'm getting from constructor:
type MyStruct struct {
...
voiceManager voice.Manager
...
}
func Constructor(voiceManager voice.Manager) MyStruct {
return MyStruct{
...
voiceManager: voiceManager,
...
}
}
And method where i'm connecting to voice room:
func (s *MyStruct) Start() error {
voiceConn := s.voiceManager.CreateConn(s.guildID)
if err := voiceConn.Open(context.Background(), s.channelID, true, false); err != nil {
return fmt.Errorf("failed to connect to voice channel: %w", err)
}
...
}
This function executes on voice channel creation event and bot actually connects to the voice room but voiceConn.Open()
never returns (or returns deadline error if you pass a context with timeout). What's more confusing is that after i tried to execute the same code that was in Start()
right after bot initialization with botClient.VoiceManager()
, the Open()
function didn't froze.
After some debugging and looking to library internals i figured out that Open()
gets stuck on waiting value from channel which as far as i understood from source code, waiting for "data session description" message:
func (c *connImpl) handleMessage(op Opcode, data GatewayMessageData) {
...
case GatewayMessageDataSessionDescription:
c.udp.SetSecretKey(d.SecretKey)
c.openedChan <- struct{}{}
}
func (c *connImpl) Open(ctx context.Context, channelID snowflake.ID, selfMute bool, selfDeaf bool) error {
c.config.Logger.Debug("opening voice conn")
if err := c.voiceStateUpdateFunc(ctx, c.state.GuildID, &channelID, selfMute, selfDeaf); err != nil {
return err
}
select {
// here we stuck on waiting value from this channel :\
case <-c.openedChan:
return nil
case <-ctx.Done():
return ctx.Err()
}
}
Here is what i'm getting from debug logs when voice channel creation event happens and then i'm calling Start()
function which never returns even though the bot joining voice room:
time=2024-05-11T20:19:33.547+03:00 level=DEBUG msg="received gateway message" name=gateway shard_id=0 shard_count=1 data="{\"t\":\"CHANNEL_CREATE\",\"s\":4,\"op\":0,\"d\":{\"version\":1715447973712,\"user_limit\":0,\"type\":2,\"rtc_region\":null,\"rate_limit_per_user\":0,\"position\":68,\"permission_overwrites\":[],\"parent_id\":\"815662015619530782\",\"nsfw\":false,\"name\":\"a\",\"last_message_id\":null,\"id\":\"1238903338918088804\",\"guild_id\":\"815656071288586282\",\"flags\":0,\"bitrate\":64000}}"
time=2024-05-11T20:19:33.548+03:00 level=DEBUG msg="sending gateway command" name=gateway shard_id=0 shard_count=1 data="{\"op\":4,\"d\":{\"guild_id\":\"815656071288586282\",\"channel_id\":\"1238903338918088804\",\"self_mute\":true,\"self_deaf\":false}}"
time=2024-05-11T20:19:33.771+03:00 level=DEBUG msg="received gateway message" name=gateway shard_id=0 shard_count=1 data="{\"t\":\"VOICE_STATE_UPDATE\",\"s\":5,\"op\":0,\"d\":{\"member\":{\"user\":{\"username\":\"voicer\",\"public_flags\":0,\"id\":\"1238045323268456488\",\"global_name\":null,\"display_name\":null,\"discriminator\":\"6595\",\"clan\":null,\"bot\":true,\"avatar_decoration_data\":null,\"avatar\":null},\"roles\":[\"1238089362927779843\"],\"premium_since\":null,\"pending\":false,\"nick\":null,\"mute\":false,\"joined_at\":\"2024-05-09T11:25:06.822000+00:00\",\"flags\":0,\"deaf\":false,\"communication_disabled_until\":null,\"avatar\":null},\"user_id\":\"1238045323268456488\",\"suppress\":false,\"session_id\":\"8cf77637e2298ee225e1dc3338cae5ed\",\"self_video\":false,\"self_mute\":true,\"self_deaf\":false,\"request_to_speak_timestamp\":null,\"mute\":false,\"guild_id\":\"815656071288586282\",\"deaf\":false,\"channel_id\":\"1238903338918088804\"}}"
But when i'm trying to open connection right after bot initialization, everything is fine and i'm getting the same output except of 1 additional log message about voice server update:
time=2024-05-11T20:29:30.994+03:00 level=DEBUG msg="received gateway message" name=gateway shard_id=0 shard_count=1 data="{\"t\":\"VOICE_SERVER_UPDATE\",\"s\":5,\"op\":0,\"d\":{\"token\":\"<session-token>\",\"guild_id\":\"815656071288586282\",\"endpoint\":\"finland10006.discord.media:443\"}}"
I have no idea why in one case everything is fine and in another it gets stuck with the same instance of voice manager (in separate runs of course). Can anyone suggest what the problem is?
Is your feature request related to a problem? Please describe.
i want to scan for invite codes with regex in user's bio
Describe the solution you'd like
add an field with the user's bio
Describe alternatives you've considered
add a function with the user's bio
Describe the bug
Seeing lots of snowflake parsing logs
Error
ERROR error while parsing gateway message name=gateway shard_id=0 shard_count=1 err="failed to unmarshal message data: {\"t\":\"GUILD_CREATE\",\"s...: failed to unquote snowflake: invalid syntax"
To Reproduce
Seems to be happening for presence updates as well.
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Disgo Version(please complete the following information):
github.com/disgoorg/disgo v0.18.8
github.com/disgoorg/snowflake/v2 v2.0.1
Additional context
Add any other context about the problem here.
Describe the bug
When i try to use discord.User.AvatarDecoration or AvatarDecorationURL() it returns null. When i tried it with postman directly on the api it seems that discord changed the json formatting for the user payload.
Error
The error which gets logged if there is any:
2024/04/07 20:30:59 ERROR recovered from panic in event listener name=bot_event_manager arg="runtime error: invalid memory address or nil pointer dereference" stack="goroutine 27 [running]:\nruntime/debug.Stack()\n\t/usr/local/go1.22.1.linux-amd64/src/runtime/debug/stack.go:24 +0x5e\ngithub.com/disgoorg/disgo/bot.(*eventManagerImpl).DispatchEvent.func1()\n\t/home/vaporvee/go/pkg/mod/github.com/disgoorg/[email protected]/bot/event_manager.go:151 +0x8c\npanic({0x7dfdc0?, 0xbcd940?})\n\t/usr/local/go1.22.1.linux-amd64/src/runtime/panic.go:770 +0x132\nmain.init.func1(0xc0000000c0)\n\t/home/vaporvee/acecore/cmd_info.go:113 +0x514\nmain.applicationCommandInteractionCreate(0xc0000000c0)\n\t/home/vaporvee/acecore/handlers.go:74 +0x204\ngithub.com/disgoorg/disgo/bot.(*listenerFunc[...]).OnEvent(...)\n\t/home/vaporvee/go/pkg/mod/github.com/disgoorg/[email protected]/bot/event_manager.go:64\ngithub.com/disgoorg/disgo/bot.(*eventManagerImpl).DispatchEvent(0xc00007a660, {0x9465d0, 0xc0000000c0})\n\t/home/vaporvee/go/pkg/mod/github.com/disgoorg/[email protected]/bot/event_manager.go:170 +0x142\ngithub.com/disgoorg/disgo/handlers.handleInteraction({0x950a90, 0xc0000a3cc0}, 0x6, 0x0, 0x0, {0x94f530, 0xc0000b4370})\n\t/home/vaporvee/go/pkg/mod/github.com/disgoorg/[email protected]/handlers/interaction_create_handler.go:43 +0x968\ngithub.com/disgoorg/disgo/handlers.gatewayHandlerInteractionCreate({0x950a90?, 0xc0000a3cc0?}, 0xc00045a2a8?, 0x7cfc40?, {{0x94f530?, 0xc0000b4370?}})\n\t/home/vaporvee/go/pkg/mod/github.com/disgoorg/[email protected]/handlers/interaction_create_handler.go:16 +0x2f\ngithub.com/disgoorg/disgo/bot.(*genericGatewayEventHandler[...]).HandleGatewayEvent(0x418545?, {0x950a90?, 0xc0000a3cc0?}, 0xc000113320?, 0x100?, {0x948588?, 0xc0002fcb00?})\n\t/home/vaporvee/go/pkg/mod/github.com/disgoorg/[email protected]/bot/event_manager.go:111 +0x4e\ngithub.com/disgoorg/disgo/bot.(*eventManagerImpl).HandleGatewayEvent(0xc00007a660, {0xc0002f63d8, 0x12}, 0x6, 0x0, {0x948588, 0xc0002fcb00})\n\t/home/vaporvee/go/pkg/mod/github.com/disgoorg/[email protected]/bot/event_manager.go:136 +0x12c\ngithub.com/disgoorg/disgo/gateway.(*gatewayImpl).listen(0xc0001e2640, 0xc000133600)\n\t/home/vaporvee/go/pkg/mod/github.com/disgoorg/[email protected]/gateway/gateway_impl.go:421 +0x16ef\ncreated by github.com/disgoorg/disgo/gateway.(*gatewayImpl).open in goroutine 1\n\t/home/vaporvee/go/pkg/mod/github.com/disgoorg/[email protected]/gateway/gateway_impl.go:125 +0x453\n"
it panics obviously when i use the returned null value
To Reproduce
Steps to reproduce the behavior:
var user discord.User = e.SlashCommandInteractionData().User("user") // get the user from my slash command (other things work with that user value)
logrus.Debug(user.AvatarDecorationURL()) // returns null
logrus.Debug(user.AvatarDecorationURL()) // returns null too
Disgo Version(please complete the following information):
Additional context
Also AccentColor seems to be broken too.
Describe the bug
Event gateway.EventTypingStart (TYPING_START
gateway event) sometimes has non-zero GuildID
field, yet nil Member
field. This results in nil pointer dereference in default library handler at https://github.com/disgoorg/disgo/blob/master/handlers/typing_start_handler.go#L26 - event.GuildID == nil
is false at this point.
Error
Here are the logs for panic:
some-bot-app-1 | panic: runtime error: invalid memory address or nil pointer dereference
some-bot-app-1 | [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xbc9d78]
some-bot-app-1 |
some-bot-app-1 | goroutine 48 [running]:
some-bot-app-1 | github.com/disgoorg/disgo/handlers.gatewayHandlerTypingStart({0x10e19f0, 0xc0000f8840}, 0x25, 0x0, {0xf9415299c442082, 0xc000455830, 0xf00804592c440be, {0x0, 0xedc2a5328, 0x16d1ca0}, ...})
some-bot-app-1 | /go/pkg/mod/github.com/disgoorg/[email protected]/handlers/typing_start_handler.go:26 +0x1b8
some-bot-app-1 | github.com/disgoorg/disgo/bot.(*genericGatewayEventHandler[...]).HandleGatewayEvent(0xa2?, {0x10e19f0?, 0xc0000f8840?}, 0xc00031a9d8?, 0xc00001b938?, {0x10d4db8?, 0xc000317dd0?})
some-bot-app-1 | /go/pkg/mod/github.com/disgoorg/[email protected]/bot/event_manager.go:105 +0xe5
some-bot-app-1 | github.com/disgoorg/disgo/bot.(*eventManagerImpl).HandleGatewayEvent(0xc00022f570, {0xc000455800, 0xc}, 0xc000035a40?, 0xc00001bbf0?, {0x10d4db8, 0xc000317dd0})
some-bot-app-1 | /go/pkg/mod/github.com/disgoorg/[email protected]/bot/event_manager.go:126 +0x11f
some-bot-app-1 | github.com/disgoorg/disgo/gateway.(*gatewayImpl).listen(0xc0001b9600, 0xc000036b00)
some-bot-app-1 | /go/pkg/mod/github.com/disgoorg/[email protected]/gateway/gateway_impl.go:419 +0x979
some-bot-app-1 | created by github.com/disgoorg/disgo/gateway.(*gatewayImpl).open
some-bot-app-1 | /go/pkg/mod/github.com/disgoorg/[email protected]/gateway/gateway_impl.go:137 +0x7ca
I've added some logging at the application level to inspect the raw payload of TYPING_START
events by registering a handler for events.Raw
. The code is as following (don't pay attention to naming):
func (e *EventController) OnRawUserTypingStart(event *events.Raw) {
if event.EventType != gateway.EventTypeTypingStart {
return
}
payload, err := io.ReadAll(event.Payload)
if err != nil {
e.logger.Debug(
"Error while reading body of Raw event TYPING_START",
slog.String("err", err.Error()),
)
return
}
e.logger.Debug(
"Got Raw event TYPING_START",
slog.String("payload", fmt.Sprintf("%q", payload)),
)
}
As it turns out, the raw event payload indeed contains guild_id
field but no member
field. Here are the logs for the last event which caused the panic above:
some-bot-app-1 | time=2023-06-25T15:24:24.166Z level=DEBUG source=/build/internal/bot/handlers/controllers/events.go:80 msg="Got Raw TYPING_START event" package=app payload="\"{\\\"user_id\\\":\\\"1081004946872352958\\\",\\\"timestamp\\\":1687706664,\\\"channel_id\\\":\\\"1122545475581649026\\\",\\\"guild_id\\\":\\\"541260942126874635\\\"}\""
To Reproduce
Steps to reproduce the behavior: can't be reproduced from the application level.
Expected behavior
The library doesn't panic.
Disgo Version(please complete the following information):
Current master, require github.com/disgoorg/disgo v0.16.6
Additional context
The bug isn't a disgo's fault, the incorrect event payload comes straight from discord. I've looked up the gateway events docs for said event, they state that the member field must always be present if the event occurs in a guild, yet it is not.
Actually I've done some research and found out when this happens. I've looked up the user for the last event which caused panic, and noticed that the user is the Clyde bot. My guess is that Clyde isn't considered a member of the guild, thus the absent member
field in event payload. This seems to be the case, as Clyde isn't displayed in guild member list and his profile can't be edited by admin.
This time Discord has broken their own API contract. I think the only thing we can do is to add an appropriate nil check in aforementioned handler. Also, I'm not sure if there will be more unforeseen issues with this Clyde bot elsewhere in the codebase.
As the title says. It seems that the HeartbeatAck event added in 0.16.0 is not implemented to be received by ListenerAdaper.
I don't know what causes this,It panics my program
I need help how should I solve this problem
It is recorded in the log that there was no user reaction message before this panic.
Error
service_stdout: panic: runtime error: invalid memory address or nil pointer dereference
[github.com/disgoorg/disgo/handlers.gatewayHandlerMessageReactionAdd](http://github.com/disgoorg/disgo/handlers.gatewayHandlerMessageReactionAdd)({0x1080270?, 0xc000456320}, 0x122, 0x0, {0xd812f2985c20000, 0xbf3fd9b5812001f, 0xef4943f5e843014, 0xc000d2bd70, 0x0, {0x0, ...}, ...})
/var/lib/jenkins/go/pkg/mod/[github.com/disgoorg/[email protected]/handlers/message_reaction_handler.go:51](http://github.com/disgoorg/[email protected]/handlers/message_reaction_handler.go:51) +0x33f
[github.com/disgoorg/disgo/bot](http://github.com/disgoorg/disgo/bot).(*genericGatewayEventHandler[...]).HandleGatewayEvent(0xc0003ad7a8?, {0x1080270?, 0xc000456320?}, 0xc0001459b8?, 0xc0003ad728?, {0x106e648?, 0xc0004609a0?})
/var/lib/jenkins/go/pkg/mod/[github.com/disgoorg/[email protected]/bot/event_manager.go:111](http://github.com/disgoorg/[email protected]/bot/event_manager.go:111) +0x105
[github.com/disgoorg/disgo/bot.(*eventManagerImpl).HandleGatewayEvent](http://github.com/disgoorg/disgo/bot.(*eventManagerImpl).HandleGatewayEvent)(0xc00022fc80, {0xc000bd05e8, 0x14}, 0x4120a5?, 0x100?, {0x106e648, 0xc0004609a0})
/var/lib/jenkins/go/pkg/mod/[github.com/disgoorg/[email protected]/bot/event_manager.go:136](http://github.com/disgoorg/[email protected]/bot/event_manager.go:136) +0x114
[github.com/disgoorg/disgo/gateway.(*gatewayImpl).listen](http://github.com/disgoorg/disgo/gateway.(*gatewayImpl).listen)(0xc0001d6000, 0xc000248160)
/var/lib/jenkins/go/pkg/mod/[github.com/disgoorg/[email protected]/gateway/gateway_impl.go:421](http://github.com/disgoorg/[email protected]/gateway/gateway_impl.go:421) +0x70c
created by [github.com/disgoorg/disgo/gateway.(*gatewayImpl).open](http://github.com/disgoorg/disgo/gateway.(*gatewayImpl).open) in goroutine 1
/var/lib/jenkins/go/pkg/mod/[github.com/disgoorg/[email protected]/gateway/gateway_impl.go:125](http://github.com/disgoorg/[email protected]/gateway/gateway_impl.go:125) +0x37a
Is your feature request related to a problem? Please describe.
The bot will not return an error when a token is invalid which can lead to a panic.
Describe the solution you'd like
On *.OpenGateway return an error if the bot cannot connect due to a invalid token/un-connectable error, that the user can handle in their nessesary way.
Describe alternatives you've considered
For now I am using latency to discover if the bot's connection was successful before proceeding to continue to actions to prevent said panic.
Additional context
In my case running multiple bots caused the bot to restart via process manager due to a bad overlook on my part with no knowledge of the error occurring that I thought was handled due to the OpenGateway returning a error, I did not understand that a bad token would not give a error for me to handle which in turn caused the main process bot's token to be reset overnight.
we should validate everything we send to discord & error
example message content too long
Describe the bug
When using OpusReader, I get a panic when reading an Opus file. I've tested the opus file and it plays in VLC, i've no reason to suspect its invalid.
I've no experience streaming audio so this entire thing is a bit of a mystery to me, otherwise i'd try to solve this and send a PR. I'm sort of stumbling in the dark. I see some functions included in the voice package that seem to be there to help with streaming audio over UDP, i'm attempting use them. Though, I noticed the examples, and the documentation both do not use these functions. I'm guessing they just haven't been updated. I'm sure there is more a chance that i've made an obvious mistake.
Error
The error which gets logged if there is any:
panic: runtime error: slice bounds out of range [:1399285583] with length 3840
To Reproduce
Steps to reproduce the behavior:
func writeAudio(conn voice.Conn) error {
file, err := os.Open("../../audio/file.opus")
if err != nil {
return err
}
r := voice.NewOpusReader(file)
b, err := r.ProvideOpusFrame()
for err != nil {
conn.UDP().Write(b)
}
r.Close()
return nil
}
The code panics at r.ProvideOpusFrame()
Expected behavior
I would expect the function to return an error, and give me some idea what is going wrong.
Disgo Version(please complete the following information):
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.