[skip ci] feat: prepare for public release

This commit is contained in:
Hampus Kraft
2026-01-02 19:27:51 +00:00
parent 197b23757f
commit 5ae825fc7d
199 changed files with 38391 additions and 33358 deletions

View File

@@ -346,7 +346,14 @@ get_voice_token(ChannelId, UserId, _SessionId, SessionPid, Latitude, Longitude)
connection_id => ConnectionId
}},
ok;
{error, {http_error, _Status, Body}} ->
case parse_unclaimed_error(Body) of
true -> SessionPid ! {voice_error, voice_unclaimed_account};
false -> SessionPid ! {voice_error, voice_token_failed}
end,
error;
{error, _Reason} ->
SessionPid ! {voice_error, voice_token_failed},
error
end.
@@ -383,6 +390,11 @@ get_dm_voice_token_and_create_state(
IsMobile,
State
);
{error, {http_error, _Status, Body}} ->
case parse_unclaimed_error(Body) of
true -> {reply, gateway_errors:error(voice_unclaimed_account), State};
false -> {reply, gateway_errors:error(voice_token_failed), State}
end;
{error, _Reason} ->
{reply, gateway_errors:error(voice_token_failed), State}
end.
@@ -501,6 +513,17 @@ disconnect_voice_user(UserId, State) ->
{reply, #{success => true}, NewState}
end.
parse_unclaimed_error(Body) when is_binary(Body) ->
try jsx:decode(Body, [return_maps]) of
#{<<"code">> := <<"UNCLAIMED_ACCOUNT_RESTRICTED">>} -> true;
#{<<"error">> := #{<<"code">> := <<"UNCLAIMED_ACCOUNT_RESTRICTED">>}} -> true;
_ -> false
catch
_:_ -> false
end;
parse_unclaimed_error(_) ->
false.
broadcast_voice_state_update(ChannelId, VoiceState, State) ->
Channels = maps:get(channels, State, #{}),

View File

@@ -644,11 +644,33 @@ request_voice_token(GuildId, ChannelId, UserId, VoicePermissions) ->
endpoint => maps:get(<<"endpoint">>, Data),
connection_id => maps:get(<<"connectionId">>, Data)
}};
{error, {http_error, _Status, Body}} ->
case parse_unclaimed_error(Body) of
true ->
{error, voice_unclaimed_account};
false ->
logger:error("[guild_voice_connection] RPC request failed: ~p", [{http_error, Body}]),
{error, voice_token_failed}
end;
{error, Reason} ->
logger:error("[guild_voice_connection] RPC request failed: ~p", [Reason]),
{error, Reason}
{error, voice_token_failed}
end.
parse_unclaimed_error(Body) when is_binary(Body) ->
try jsx:decode(Body, [return_maps]) of
#{<<"code">> := <<"UNCLAIMED_ACCOUNT_RESTRICTED">>} ->
true;
#{<<"error">> := #{<<"code">> := <<"UNCLAIMED_ACCOUNT_RESTRICTED">>}} ->
true;
_ ->
false
catch
_:_ -> false
end;
parse_unclaimed_error(_) ->
false.
-spec pending_voice_connections(guild_state()) -> pending_voice_connections().
pending_voice_connections(State) ->
case maps:get(pending_voice_connections, State, undefined) of