@magicyan/discord 1.0.7 → 1.0.8

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.
@@ -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;
@@ -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({ user, property = "displayName", imageSize: size = 512, iconURL, url, prefix = "", suffix = "" }) {
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magicyan/discord",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
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.8"
31
+ "@magicyan/core": "^1.0.9"
32
32
  },
33
33
  "peerDependencies": {
34
- "discord.js": "^14.13.0"
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
- export declare function createEmbedAuthor({ user, property, imageSize: size, iconURL, url, prefix, suffix }: {
1
+ import type { EmbedAuthorData, ImageURLOptions, User } from "discord.js";
2
+ interface CreateEmbedAuthorOptions {
3
3
  user: User;
4
- property?: keyof Pick<User, "username" | "displayName" | "id">;
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
- }): EmbedAuthorData;
10
+ }
11
+ export declare function createEmbedAuthor(options: CreateEmbedAuthorOptions): EmbedAuthorData;
12
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { Guild } from "discord.js";
2
+ export declare function findRole(guild: Guild): {
3
+ byName(name: string): import("discord.js").Role | undefined;
4
+ byId(id: string): import("discord.js").Role | undefined;
5
+ };
@@ -1,4 +1,7 @@
1
- import { ActionRowBuilder, AnyComponentBuilder, ButtonBuilder, LinkButtonComponentData, TextInputBuilder, TextInputComponentData } from "discord.js";
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
- export declare function createLinkButton(data: Omit<LinkButtonComponentData, "style" | "type">): ButtonBuilder;
5
+ type CreateLinkButtonData = Omit<LinkButtonComponentData, "style" | "type">;
6
+ export declare function createLinkButton(data: CreateLinkButtonData): ButtonBuilder;
7
+ export {};