diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/extensions/discord.js/BushGuild.ts | 2 | ||||
-rw-r--r-- | src/lib/extensions/discord.js/BushGuildChannelManager.ts | 112 | ||||
-rw-r--r-- | src/lib/extensions/discord.js/BushGuildMember.ts | 2 | ||||
-rw-r--r-- | src/lib/utils/BushConstants.ts | 4 |
4 files changed, 105 insertions, 15 deletions
diff --git a/src/lib/extensions/discord.js/BushGuild.ts b/src/lib/extensions/discord.js/BushGuild.ts index b13d0f8..93875b8 100644 --- a/src/lib/extensions/discord.js/BushGuild.ts +++ b/src/lib/extensions/discord.js/BushGuild.ts @@ -371,7 +371,7 @@ export class BushGuild extends Guild { author: { name: moderator.user.tag, icon_url: moderator.displayAvatarURL() }, title: `This channel has been ${options.unlock ? 'un' : ''}locked`, description: options.reason ?? 'No reason provided', - color: options.unlock ? util.colors.GREEN : util.colors.RED, + color: options.unlock ? util.colors.Green : util.colors.Red, timestamp: new Date().toISOString() } ] diff --git a/src/lib/extensions/discord.js/BushGuildChannelManager.ts b/src/lib/extensions/discord.js/BushGuildChannelManager.ts index 029f7d3..91bff07 100644 --- a/src/lib/extensions/discord.js/BushGuildChannelManager.ts +++ b/src/lib/extensions/discord.js/BushGuildChannelManager.ts @@ -2,12 +2,19 @@ import type { BushFetchedThreads, BushGuild, BushGuildBasedChannel, + BushGuildChannel, BushMappedGuildChannelTypes, BushNonThreadGuildBasedChannel, - BushStoreChannel + BushStoreChannel, + BushTextChannel } from '#lib'; import { CachedManager, + ChannelData, + ChannelType, + ChannelWebhookCreateOptions, + SetChannelPositionOptions, + Webhook, type BaseFetchOptions, type ChannelPosition, type Collection, @@ -59,27 +66,70 @@ export declare class BushGuildChannelManager * }, * ], * }) - * @deprecated See [Self-serve Game Selling Deprecation](https://support-dev.discord.com/hc/en-us/articles/4414590563479) for more information */ - // eslint-disable-next-line deprecation/deprecation - public create(name: string, options: GuildChannelCreateOptions & { type: 'GuildStore' }): Promise<BushStoreChannel>; + public create<T extends Exclude<GuildChannelTypes, ChannelType.GuildStore>>( + name: string, + options: GuildChannelCreateOptions & { type: T } + ): Promise<BushMappedGuildChannelTypes[T]>; /** * Creates a new channel in the guild. * @param name The name of the new channel * @param options Options for creating the new channel + * @example + * // Create a new text channel + * guild.channels.create('new-general', { reason: 'Needed a cool new channel' }) + * .then(console.log) + * .catch(console.error); + * @example + * // Create a new channel with permission overwrites + * guild.channels.create('new-voice', { + * type: 'GuildVoice', + * permissionOverwrites: [ + * { + * id: message.author.id, + * deny: [PermissionFlagsBits.ViewChannel], + * }, + * ], + * }) + * @deprecated See [Self-serve Game Selling Deprecation](https://support-dev.discord.com/hc/en-us/articles/4414590563479) for more information */ - public create<T extends GuildChannelTypes>( + public create( name: string, - options: GuildChannelCreateOptions & { type: T } - ): Promise<BushMappedGuildChannelTypes[T]>; + options: GuildChannelCreateOptions & { type: ChannelType.GuildStore } + ): // eslint-disable-next-line deprecation/deprecation + Promise<BushStoreChannel>; + public create(name: string, options?: GuildChannelCreateOptions): Promise<BushTextChannel>; /** - * Creates a new channel in the guild. - * @param name The name of the new channel - * @param options Options for creating the new channel + * Creates a webhook for the channel. + * @param channel The channel to create the webhook for + * @param name The name of the webhook + * @param options Options for creating the webhook + * @returns Returns the created Webhook + * @example + * // Create a webhook for the current channel + * guild.channels.createWebhook('222197033908436994', 'Snek', { + * avatar: 'https://i.imgur.com/mI8XcpG.jpg', + * reason: 'Needed a cool new Webhook' + * }) + * .then(console.log) + * .catch(console.error) */ - public create(name: string, options: GuildChannelCreateOptions): Promise<BushNonThreadGuildBasedChannel>; + public createWebhook(channel: GuildChannelResolvable, name: string, options?: ChannelWebhookCreateOptions): Promise<Webhook>; + + /** + * Edits the channel. + * @param channel The channel to edit + * @param data The new data for the channel + * @param reason Reason for editing this channel + * @example + * // Edit a channel + * guild.channels.edit('222197033908436994', { name: 'new-channel' }) + * .then(console.log) + * .catch(console.error); + */ + public edit(channel: GuildChannelResolvable, data: ChannelData, reason?: string): Promise<BushGuildChannel>; /** * Obtains one or more guild channels from Discord, or the channel cache if they're already available. @@ -100,6 +150,34 @@ export declare class BushGuildChannelManager public fetch(id?: undefined, options?: BaseFetchOptions): Promise<Collection<Snowflake, BushNonThreadGuildBasedChannel>>; /** + * Fetches all webhooks for the channel. + * @param channel The channel to fetch webhooks for + * @example + * // Fetch webhooks + * guild.channels.fetchWebhooks('769862166131245066') + * .then(hooks => console.log(`This channel has ${hooks.size} hooks`)) + * .catch(console.error); + */ + public fetchWebhooks(channel: GuildChannelResolvable): Promise<Collection<Snowflake, Webhook>>; + + /** + * Sets a new position for the guild channel. + * @param channel The channel to set the position for + * @param position The new position for the guild channel + * @param options Options for setting position + * @example + * // Set a new channel position + * guild.channels.setPosition('222078374472843266', 2) + * .then(newChannel => console.log(`Channel's new position is ${newChannel.position}`)) + * .catch(console.error); + */ + public setPosition( + channel: GuildChannelResolvable, + position: number, + options?: SetChannelPositionOptions + ): Promise<BushGuildChannel>; + + /** * Batch-updates the guild's channels' positions. * <info>Only one channel's parent can be changed at a time</info> * @param channelPositions Channel positions to update @@ -120,4 +198,16 @@ export declare class BushGuildChannelManager * .catch(console.error); */ public fetchActiveThreads(cache?: boolean): Promise<BushFetchedThreads>; + + /** + * Deletes the channel. + * @param channel The channel to delete + * @param reason Reason for deleting this channel + * @example + * // Delete the channel + * guild.channels.delete('858850993013260338', 'making room for new channels') + * .then(console.log) + * .catch(console.error); + */ + public delete(channel: GuildChannelResolvable, reason?: string): Promise<void>; } diff --git a/src/lib/extensions/discord.js/BushGuildMember.ts b/src/lib/extensions/discord.js/BushGuildMember.ts index ab6cd65..84fdf13 100644 --- a/src/lib/extensions/discord.js/BushGuildMember.ts +++ b/src/lib/extensions/discord.js/BushGuildMember.ts @@ -1123,7 +1123,7 @@ export type TimeoutResponse = ValueOf<typeof timeoutResponse>; */ export type RemoveTimeoutResponse = ValueOf<typeof removeTimeoutResponse>; -export type PartialBushGuildMember = Partialize<BushGuildMember, 'joinedAt' | 'joinedTimestamp'>; +export type PartialBushGuildMember = Partialize<BushGuildMember, 'joinedAt' | 'joinedTimestamp' | 'pending'>; /** * @typedef {BushClientEvents} VSCodePleaseDontRemove diff --git a/src/lib/utils/BushConstants.ts b/src/lib/utils/BushConstants.ts index 5b2b2e6..4327fec 100644 --- a/src/lib/utils/BushConstants.ts +++ b/src/lib/utils/BushConstants.ts @@ -1,4 +1,4 @@ -import { Constants } from 'discord.js'; +import { Colors } from 'discord.js'; import { BushClientUtil } from '../extensions/discord-akairo/BushClientUtil.js'; const rawCapeUrl = 'https://raw.githubusercontent.com/NotEnoughUpdates/capes/master/'; @@ -107,7 +107,7 @@ export class BushConstants { darkGray: 0x7a7a7a, black: 0x000000, orange: 0xe86100, - ...Constants.Colors + ...Colors } as const); // Somewhat stolen from @Mzato0001 |