@magicyan/discord 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/dist/functions/channels.js +16 -0
- package/dist/functions/embeds.js +2 -1
- package/dist/functions/roles.js +14 -0
- package/dist/index.js +3 -1
- package/package.json +3 -3
- package/types/functions/channels.d.ts +10 -0
- package/types/functions/embeds.d.ts +6 -4
- package/types/functions/roles.d.ts +5 -0
- package/types/functions/utils.d.ts +5 -2
- package/types/index.d.ts +3 -1
package/README.md
CHANGED
|
@@ -92,4 +92,18 @@ new EmbedBuilder({
|
|
|
92
92
|
author: createEmbedAuthor({ user }),
|
|
93
93
|
description: "My embed description"
|
|
94
94
|
})
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Function to find a channel from the guild cache
|
|
98
|
+
```ts
|
|
99
|
+
const { guild } = interaction
|
|
100
|
+
|
|
101
|
+
const channel = findChannel(guild, ChannelType.GuildVoice).byName("Lounge 01") // VoiceChannel | undefined
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Function to find a role from the guild cache
|
|
105
|
+
```ts
|
|
106
|
+
const { guild } = interaction
|
|
107
|
+
|
|
108
|
+
const role = findChannel(guild).byName("Administrator") // Role | undefined
|
|
95
109
|
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findChannel = void 0;
|
|
4
|
+
const discord_js_1 = require("discord.js");
|
|
5
|
+
function findChannel(guild, type) {
|
|
6
|
+
const channelType = type || discord_js_1.ChannelType.GuildText;
|
|
7
|
+
return {
|
|
8
|
+
byName(name) {
|
|
9
|
+
return guild.channels.cache.find(c => c.name === name && c.type === channelType);
|
|
10
|
+
},
|
|
11
|
+
byId(id) {
|
|
12
|
+
return guild.channels.cache.find(c => c.id === id && c.type === channelType);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
exports.findChannel = findChannel;
|
package/dist/functions/embeds.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createEmbedAuthor = void 0;
|
|
4
|
-
function createEmbedAuthor(
|
|
4
|
+
function createEmbedAuthor(options) {
|
|
5
|
+
const { user, property = "displayName", imageSize: size = 512, iconURL, url, prefix = "", suffix = "" } = options;
|
|
5
6
|
return {
|
|
6
7
|
name: `${prefix}${user[property]}${suffix}`, url,
|
|
7
8
|
iconURL: iconURL || user.displayAvatarURL({ size })
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findRole = void 0;
|
|
4
|
+
function findRole(guild) {
|
|
5
|
+
return {
|
|
6
|
+
byName(name) {
|
|
7
|
+
return guild.roles.cache.find(role => role.name == name);
|
|
8
|
+
},
|
|
9
|
+
byId(id) {
|
|
10
|
+
return guild.roles.cache.get(id);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
exports.findRole = findRole;
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./constants/client"), exports);
|
|
18
|
-
__exportStar(require("./functions/
|
|
18
|
+
__exportStar(require("./functions/channels"), exports);
|
|
19
19
|
__exportStar(require("./functions/embeds"), exports);
|
|
20
|
+
__exportStar(require("./functions/roles"), exports);
|
|
21
|
+
__exportStar(require("./functions/utils"), exports);
|
|
20
22
|
__exportStar(require("@magicyan/core"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magicyan/discord",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"homepage": "https://github.com/rinckodev/magicyan/tree/main/packages/discord#readme",
|
|
29
29
|
"description": "Simple functions to facilitate discord bot development",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@magicyan/core": "^1.0.
|
|
31
|
+
"@magicyan/core": "^1.0.9"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"discord.js": "^14.
|
|
34
|
+
"discord.js": "^14.14.1"
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CommandInteractionOption, Guild } from "discord.js";
|
|
2
|
+
import { ChannelType } from "discord.js";
|
|
3
|
+
type GetChannelType<Type extends ChannelType> = Extract<NonNullable<CommandInteractionOption<"cached">["channel"]>, {
|
|
4
|
+
type: Type extends ChannelType.PublicThread | ChannelType.AnnouncementThread ? ChannelType.PublicThread | ChannelType.AnnouncementThread : Type;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function findChannel<Type extends Exclude<ChannelType, ChannelType.DM> = ChannelType.GuildText>(guild: Guild, type?: Type): {
|
|
7
|
+
byName(name: string): GetChannelType<Type> | undefined;
|
|
8
|
+
byId(id: string): GetChannelType<Type> | undefined;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { EmbedAuthorData, ImageURLOptions, User } from "discord.js";
|
|
2
|
-
|
|
1
|
+
import type { EmbedAuthorData, ImageURLOptions, User } from "discord.js";
|
|
2
|
+
interface CreateEmbedAuthorOptions {
|
|
3
3
|
user: User;
|
|
4
|
-
property?:
|
|
4
|
+
property?: "username" | "displayName" | "id" | "globalName";
|
|
5
5
|
imageSize?: ImageURLOptions["size"];
|
|
6
6
|
iconURL?: string;
|
|
7
7
|
url?: string;
|
|
8
8
|
prefix?: string;
|
|
9
9
|
suffix?: string;
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
|
+
export declare function createEmbedAuthor(options: CreateEmbedAuthorOptions): EmbedAuthorData;
|
|
12
|
+
export {};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AnyComponentBuilder, LinkButtonComponentData, TextInputComponentData } from "discord.js";
|
|
2
|
+
import { ActionRowBuilder, TextInputBuilder, ButtonBuilder } from "discord.js";
|
|
2
3
|
export declare function createRow<Component extends AnyComponentBuilder>(...components: Component[]): ActionRowBuilder<Component>;
|
|
3
4
|
export declare function createModalInput(data: Omit<TextInputComponentData, "type">): ActionRowBuilder<TextInputBuilder>;
|
|
4
|
-
|
|
5
|
+
type CreateLinkButtonData = Omit<LinkButtonComponentData, "style" | "type">;
|
|
6
|
+
export declare function createLinkButton(data: CreateLinkButtonData): ButtonBuilder;
|
|
7
|
+
export {};
|
package/types/index.d.ts
CHANGED