Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: v4.7.0 update #35

Merged
merged 12 commits into from
Oct 19, 2023
2 changes: 1 addition & 1 deletion docs/contributing/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ errors later.
## Questions?

If you have any questions, feel free to ask in our [Discord server](https://discord.gg/replugged) in
the `#replugged-core` channel.
the `#replugged-dev` channel.

## Thank you!

Expand Down
2 changes: 1 addition & 1 deletion docs/contributing/replugged.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ errors later.
## Questions?

If you have any questions, feel free to ask in our [Discord server](https://discord.gg/replugged) in
the `#replugged-core` channel.
the `#replugged-dev` channel.

## Thank you!

Expand Down
9 changes: 5 additions & 4 deletions docs/manifest.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ All keys in the [common section](#common), as well as the following:

All keys in the [common section](#common), as well as the following:

| Key | Type | Description |
| ---------------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| type&nbsp;<Required /> | 'replugged-theme' | Must be `replugged-theme`. |
| main&nbsp;<Required /> | string | The path to the main entrypoint of your theme (CSS). The [theme template](https://github.com/replugged-org/theme-template) will allow you to also use SCSS and will handle compiling and updating the file location for you. |
| Key | Type | Description |
| ---------------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| type&nbsp;<Required /> | 'replugged-theme' | Must be `replugged-theme`. |
| main | string | The path to the main entrypoint of your theme (CSS). The [theme template](https://github.com/replugged-org/theme-template) will allow you to also use SCSS and will handle compiling and updating the file location for you. |
| splash | string | The path to Discord's splash screen entrypoint of your theme (CSS). The [theme template](https://github.com/replugged-org/theme-template) will allow you to also use SCSS and will handle compiling and updating the file location for you. |

## Types

Expand Down
70 changes: 69 additions & 1 deletion docs/plugins/injecting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ The injector class has an `uninjectAll` method which will remove all injections

```ts
import { Injector } from "replugged";

const injector = new Injector();

export function start() {
Expand All @@ -130,7 +131,7 @@ buttons that are shown in the top right corner when you hover over a message, li
reply, etc. The button order cannot be controlled.

```ts
import { Injector, webpack } from "replugged";
import { Injector } from "replugged";

const injector = new Injector();

Expand Down Expand Up @@ -211,3 +212,70 @@ export function stop(): void {

More examples can be found
[here](https://github.com/asportnoy/context-menu-demo/blob/main/src/index.tsx).

### Slash Commands

You can use the `registerSlashCommand` util to register a custom slash command under the Replugged
command section. In the following example we are registering a slash command which sends a normal
message or an <APIReferences.Embed />, based on the value of the option.

:::info

The slash commands API is supported by TypeScript. An error will occur if you try to get the value
of a nonexistent option in the registered slash command.

:::

```tsx
import { Injector, types } from "replugged";
const { ApplicationCommandOptionType } = types;

const injector = new Injector();

export function start(): void {
injector.utils.registerSlashCommand({
name: "my-command",
description: "Helpful command description",
options: [
{
name: "my-option",
description: "Very cool option description",
type: ApplicationCommandOptionType.Boolean,
required: true,
},
],
executor: (interaction) => {
// You can access the guild and channel of where the command
// was executed with interaction.guild and interaction.channel

// Get the value of the option
const sendEmbed = interaction.getValue("my-option");

if (sendEmbed) {
return {
// Whether the message should be sent in the channel;
// By setting it to false, the message will be hidden
// from anyone except the executor of the slash command
send: false,
result: "This is a message",
};
} else {
return {
send: false,
embeds: [
{
color: 0x5865f2,
title: "Embed title",
description: "Embed description",
},
],
};
}
},
});
}

export function stop(): void {
injector.uninjectAll();
}
```
56 changes: 33 additions & 23 deletions docs/plugins/modules/common/stores/channels.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,36 @@ import RequiredNotice from "@site/src/components/RequiredNotice.mdx";

### Functions

| Name | Parameters | Return Type | Description |
| ---------------------------------------- | ------------------------------------------------------------------ | ---------------------------------------------- | ----------------------------------------------------------- |
| `getAllThreadsForParent` | <Required /> `channelId`: string | <APIReferences.Channel />[] | Gets all fetched threads by its channel (parent) id |
| `getBasicChannel` | <Required /> `channelId`: string | <APIReferences.Channel /> \| undefined | Gets the basic channel by its id |
| `getChannel` | <Required /> `channelId`: string | <APIReferences.Channel /> \| undefined | Gets the channel by its id |
| `getChannelId` | <Required /> `guildId`: string <br /> `fallbackToDefault`: boolean | string \| undefined | Gets the current selected channel id |
| `getCurrentlySelectedChannelId` | `guildId`: string | string \| undefined | Gets the current selected channel id |
| `getDMFromUserId` | <Required /> `userId`: string | string \| undefined | Gets the DM channel id by its user id |
| `getDMUserIds` | | string[] | Gets all DM channel ids |
| `getGuildChannelsVersion` | <Required /> `guildId`: string | number | Gets the channel version by guild id |
| `getInitialOverlayState` | | Record<string,&nbsp;<APIReferences.Channel />> | Gets all guild and DM channels |
| `getLastChannelFollowingDestination` | | { channelId: string, guildId: string } | Gets information on the last channel follow |
| `getLastSelectedChannelId` | `guildId`: string | string \| undefined | Gets the last selected channel id |
| `getLastSelectedChannels` | <Required /> `guildId`: string | string \| undefined | Gets the last selected channel id by its guild id |
| `getMostRecentSelectedTextChannelId` | `guildId`: string | string \| null | Gets the last selected text channel id by its guild id |
| `getMutableBasicGuildChannelsForGuild` | <Required /> `guildId`: string | Record<string,&nbsp;<APIReferences.Channel />> | Gets all basic channels by its guild id |
| `getMutableGuildChannelsForGuild` | <Required /> `guildId`: string | Record<string,&nbsp;<APIReferences.Channel />> | Gets all channels by its guild id |
| `getMutablePrivateChannels` | | Record<string,&nbsp;<APIReferences.Channel />> | Gets all DM channels |
| `getPrivateChannelsVersion` | | number | Gets the DM channel version |
| `getSortedPrivateChannels` | | <APIReferences.Channel />[] | Gets all DM channels sorted by the last message |
| `getVoiceChannelId` | | string \| null | Gets the current voice channel id |
| `hasChannel` | <Required /> `channelId`: string | boolean | Checks if the channel id is registered in the channel store |
| `loadAllGuildAndPrivateChannelsFromDisk` | | Record<string,&nbsp;<APIReferences.Channel />> | Gets all guild and DM channels |
| Name | Parameters | Return Type | Description |
| ---------------------------------------- | ----------------------------------------------------- | --------------------------------------------------------------------- | ----------------------------------------------------------- |
| `getAllThreadsForParent` | <Required /> `channelId`: string | <APIReferences.Channel />[] | Gets all fetched threads by its channel (parent) id |
| `getBasicChannel` | <Required /> `channelId`: string | <APIReferences.Channel /> \| undefined | Gets the basic channel by its id |
| `getChannel` | <Required /> `channelId`: string | <APIReferences.Channel /> \| undefined | Gets the channel by its id |
| `getChannelId` | `guildId`: string <br /> `fallbackToDefault`: boolean | string \| undefined | Gets the current selected channel id |
| `getChannelIds` | `guildId`: string | string[] | Gets all channel ids |
| `getCurrentlySelectedChannelId` | `guildId`: string | string \| undefined | Gets the current selected channel id |
| `getDMFromUserId` | <Required /> `userId`: string | string \| undefined | Gets the DM channel id by its user id |
| `getDMUserIds` | | string[] | Gets all DM channel ids |
| `getGuildChannelsVersion` | <Required /> `guildId`: string | number | Gets the channel version by guild id |
| `getInitialOverlayState` | | Record<string,&nbsp;<APIReferences.Channel />> | Gets all guild and DM channels |
| `getLastChannelFollowingDestination` | | [`LastChannelFollowingDestination`](#LastChannelFollowingDestination) | Gets information on the last channel follow |
| `getLastSelectedChannelId` | `guildId`: string | string \| undefined | Gets the last selected channel id |
| `getLastSelectedChannels` | <Required /> `guildId`: string | string \| undefined | Gets the last selected channel id by its guild id |
| `getMostRecentSelectedTextChannelId` | `guildId`: string | string \| null | Gets the last selected text channel id by its guild id |
| `getMutableBasicGuildChannelsForGuild` | <Required /> `guildId`: string | Record<string,&nbsp;<APIReferences.Channel />> | Gets all basic channels by its guild id |
| `getMutableGuildChannelsForGuild` | <Required /> `guildId`: string | Record<string,&nbsp;<APIReferences.Channel />> | Gets all channels by its guild id |
| `getMutablePrivateChannels` | | Record<string,&nbsp;<APIReferences.Channel />> | Gets all DM channels |
| `getPrivateChannelsVersion` | | number | Gets the DM channel version |
| `getSortedPrivateChannels` | | <APIReferences.Channel />[] | Gets all DM channels sorted by the last message |
| `getVoiceChannelId` | | string \| null | Gets the current voice channel id |
| `hasChannel` | <Required /> `channelId`: string | boolean | Checks if the channel id is registered in the channel store |
| `loadAllGuildAndPrivateChannelsFromDisk` | | Record<string,&nbsp;<APIReferences.Channel />> | Gets all guild and DM channels |

### Types {#channels-types}

#### `LastChannelFollowingDestination` {#LastChannelFollowingDestination}

| Name | Type | Description |
| ----------- | ------ | --------------------------------------- |
| `channelId` | string | Channel id of the last followed channel |
| `guildId` | string | Guild id of the last followed channel |
Loading
Loading