mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-01 00:10:07 +00:00
Merge branch 'main' into discord-prs
This commit is contained in:
2
.github/CODEOWNERS
vendored
2
.github/CODEOWNERS
vendored
@@ -1 +1 @@
|
||||
* @Skillz4Killz @itohatweb
|
||||
* @ayntee @Skillz4Killz @itohatweb
|
||||
|
||||
16
.github/workflows/test.yml
vendored
16
.github/workflows/test.yml
vendored
@@ -16,16 +16,16 @@ jobs:
|
||||
deno-version: ${{ matrix.deno }}
|
||||
- name: Cache dependencies
|
||||
run: deno cache --no-check mod.ts
|
||||
- name: Run test script for Devs
|
||||
if: ${{ github.actor == 'Skillz4Killz' || github.actor == 'itohatweb' }}
|
||||
run: deno test --unstable --coverage=coverage -A --no-check tests/mod.ts
|
||||
- name: Run test script for label
|
||||
- name: Run test script for maintainers
|
||||
if: ${{ github.actor === "ayntee" || github.actor == 'Skillz4Killz' || github.actor == 'itohatweb' }}
|
||||
run: deno test --unstable --coverage=./coverage -A --no-check tests/mod.ts
|
||||
- name: Run test script if label added
|
||||
if: ${{ github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name == 'run-tests' }}
|
||||
run: DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }} deno test --unstable --coverage=coverage -A --no-check tests/mod.ts
|
||||
run: DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }} deno test --unstable --coverage=./coverage --allow-net --no-check tests/mod.ts
|
||||
- name: Create coverage report
|
||||
run: deno --unstable coverage ./coverage --lcov > coverage.lcov # create coverage report
|
||||
- name: Collect coverage
|
||||
uses: codecov/codecov-action@v1.0.10 # upload the report on Codecov
|
||||
run: deno --unstable coverage ./coverage --lcov > coverage.lcov
|
||||
- name: Collect and upload the coverage report
|
||||
uses: codecov/codecov-action@v1.0.10
|
||||
with:
|
||||
file: ./coverage.lcov
|
||||
env:
|
||||
|
||||
28
src/helpers/guilds/update_bot_voice_state.ts
Normal file
28
src/helpers/guilds/update_bot_voice_state.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { RequestManager } from "../../rest/request_manager.ts";
|
||||
import {
|
||||
DiscordUpdateSelfVoiceState,
|
||||
UpdateSelfVoiceState,
|
||||
} from "../../types/guilds/update_self_voice_state.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { camelKeysToSnakeCase } from "../../util/utils.ts";
|
||||
|
||||
/**
|
||||
* Updates the current user's voice state.
|
||||
* Caveats:
|
||||
* - `channel_id` must currently point to a stage channel.
|
||||
* - current user must already have joined `channel_id`.
|
||||
* - You must have the `MUTE_MEMBERS` permission to unsuppress yourself. You can always suppress yourself.
|
||||
* - You must have the `REQUEST_TO_SPEAK` permission to request to speak. You can always clear your own request to speak.
|
||||
* - You are able to set `request_to_speak_timestamp` to any present or future time.
|
||||
*/
|
||||
export function updateBotVoiceState(
|
||||
guildId: string,
|
||||
data: UpdateSelfVoiceState,
|
||||
) {
|
||||
const payload = camelKeysToSnakeCase<DiscordUpdateSelfVoiceState>(data);
|
||||
|
||||
return RequestManager.patch(
|
||||
endpoints.UPDATE_VOICE_STATE(guildId),
|
||||
payload,
|
||||
);
|
||||
}
|
||||
29
src/helpers/guilds/update_user_voice_state.ts
Normal file
29
src/helpers/guilds/update_user_voice_state.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { RequestManager } from "../../rest/request_manager.ts";
|
||||
import {
|
||||
DiscordUpdateOthersVoiceState,
|
||||
UpdateOthersVoiceState,
|
||||
} from "../../types/guilds/update_others_voice_state.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { camelKeysToSnakeCase } from "../../util/utils.ts";
|
||||
|
||||
/**
|
||||
* Updates another user's voice state.
|
||||
* Caveats:
|
||||
* - `channel_id` must currently point to a stage channel.
|
||||
* - User must already have joined `channel_id`.
|
||||
* - You must have the `MUTE_MEMBERS` permission. (Since suppression is the only thing that is available currently.)
|
||||
* - When unsuppressed, non-bot users will have their `request_to_speak_timestamp` set to the current time. Bot users will not.
|
||||
* - When suppressed, the user will have their `request_to_speak_timestamp` removed.
|
||||
*/
|
||||
export function updateVoiceState(
|
||||
guildId: string,
|
||||
userId: string,
|
||||
data: UpdateOthersVoiceState,
|
||||
) {
|
||||
const payload = camelKeysToSnakeCase<DiscordUpdateOthersVoiceState>(data);
|
||||
|
||||
return RequestManager.patch(
|
||||
endpoints.UPDATE_VOICE_STATE(guildId, userId),
|
||||
payload,
|
||||
);
|
||||
}
|
||||
13
src/types/guilds/update_others_voice_state.ts
Normal file
13
src/types/guilds/update_others_voice_state.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { SnakeCaseProps } from "../util.ts";
|
||||
|
||||
export interface UpdateOthersVoiceState {
|
||||
/** The id of the channel the user is currently in */
|
||||
channelId: string;
|
||||
/** Toggles the user's suppress state */
|
||||
suppress?: boolean;
|
||||
}
|
||||
|
||||
// TODO: add corresponding link to the resource
|
||||
export type DiscordUpdateOthersVoiceState = SnakeCaseProps<
|
||||
UpdateOthersVoiceState
|
||||
>;
|
||||
13
src/types/guilds/update_self_voice_state.ts
Normal file
13
src/types/guilds/update_self_voice_state.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { SnakeCaseProps } from "../util.ts";
|
||||
|
||||
export interface UpdateSelfVoiceState {
|
||||
/** The id of the channel the user is currently in */
|
||||
channelId: string;
|
||||
/** Toggles the user's suppress state */
|
||||
suppress?: boolean;
|
||||
/** Sets the user's request to speak */
|
||||
requestToSpeakTimestamp?: string | null;
|
||||
}
|
||||
|
||||
// TODO: add corresponding link to the resource
|
||||
export type DiscordUpdateSelfVoiceState = SnakeCaseProps<UpdateSelfVoiceState>;
|
||||
@@ -64,6 +64,6 @@ export enum DiscordBitwisePermissionFlags {
|
||||
MANAGE_EMOJIS = 0x40000000,
|
||||
/** Allows members to use slash commands in text channels */
|
||||
USE_SLASH_COMMANDS = 0x80000000,
|
||||
/** Allows for requesting to speak in stage channels. (This permission is under active development and may be changed or removed.) */
|
||||
/** Allows for requesting to speak in stage channels. */
|
||||
REQUEST_TO_SPEAK = 0x100000000,
|
||||
}
|
||||
|
||||
@@ -119,6 +119,8 @@ export const endpoints = {
|
||||
`${baseEndpoints.BASE_URL}/guilds/templates/${code}`,
|
||||
GUILD_TEMPLATES: (guildId: string) => `${GUILDS_BASE(guildId)}/templates`,
|
||||
GUILD_PREVIEW: (guildId: string) => `${GUILDS_BASE(guildId)}/preview`,
|
||||
UPDATE_VOICE_STATE: (guildId: string, userId?: string) =>
|
||||
`${GUILDS_BASE(guildId)}/voice-states/${userId ?? "@me"}`,
|
||||
|
||||
// Voice
|
||||
VOICE_REGIONS: `${baseEndpoints.BASE_URL}/voice/regions`,
|
||||
|
||||
Reference in New Issue
Block a user