Skip to content

Commit

Permalink
fix the two new Gateway functions + their test
Browse files Browse the repository at this point in the history
  • Loading branch information
MahdiBM committed Feb 6, 2023
1 parent d5ac55e commit 723e00a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Sources/DiscordGateway/BotGatewayManager.swift
Expand Up @@ -244,20 +244,20 @@ public actor BotGatewayManager: GatewayManager {

/// https://discord.com/developers/docs/topics/gateway-events#update-presence
public func updatePresence(payload: Gateway.Identify.Presence) {
/// This took a lot of time to figure out, not sure why it needs opcode `1`.
/// This took a lot of time to figure out, not sure why it needs opcode `9` (works with `10` too?!).
self.send(payload: .init(
opcode: .presenceUpdate,
data: .requestPresenceUpdate(payload)
), opcode: 1)
), opcode: 9)
}

/// https://discord.com/developers/docs/topics/gateway-events#update-voice-state
public func updateVoiceState(payload: VoiceStateUpdate) {
/// This took a lot of time to figure out, not sure why it needs opcode `1`.
/// This took a lot of time to figure out, not sure why it needs opcode `10` (works with `9` too?!).
self.send(payload: .init(
opcode: .voiceStateUpdate,
data: .requestVoiceStateUpdate(payload)
), opcode: 1)
), opcode: 10)
}

/// Adds a handler to be notified of events.
Expand Down
1 change: 1 addition & 0 deletions Tests/IntegrationTests/GatwayConnection.swift
Expand Up @@ -178,6 +178,7 @@ class GatewayConnectionTests: XCTestCase {
/// To make sure it doesn't mess up other connections,
/// and to make sure we don't get invalid-session-ed.
try await Task.sleep(nanoseconds: 10_000_000_000)
XCTAssertEqual(bot.connectionId.load(ordering: .relaxed), 1)

await bot.disconnect()

Expand Down

0 comments on commit 723e00a

Please sign in to comment.