mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 20:46:08 +00:00
feat: return channel type in channel guild create (#334)
* feat: return channel type in channel guild create also, my skill issue forced me to create a new type * refactor: use SeyfertChannelMap
This commit is contained in:
parent
84a0ce6754
commit
225778823e
@ -9,7 +9,15 @@ import {
|
||||
type StickerStructure,
|
||||
Transformers,
|
||||
} from '../../client/transformers';
|
||||
import { type AllChannels, BaseChannel, type CreateStickerBodyRequest, Guild, channelFrom } from '../../structures';
|
||||
import type { SeyfertChannelMap } from '../../commands';
|
||||
import {
|
||||
type AllChannels,
|
||||
BaseChannel,
|
||||
type CreateStickerBodyRequest,
|
||||
Guild,
|
||||
type GuildChannelTypes,
|
||||
channelFrom,
|
||||
} from '../../structures';
|
||||
import type {
|
||||
APIChannel,
|
||||
APISticker,
|
||||
@ -153,10 +161,13 @@ export class GuildShorter extends BaseShorter {
|
||||
* @param body The data for creating the channel.
|
||||
* @returns A Promise that resolves to the created channel.
|
||||
*/
|
||||
create: async (guildId: string, body: RESTPostAPIGuildChannelJSONBody) => {
|
||||
create: async <T extends GuildChannelTypes = GuildChannelTypes>(
|
||||
guildId: string,
|
||||
body: RESTPostAPIGuildChannelJSONBody & { type: T },
|
||||
): Promise<SeyfertChannelMap[T]> => {
|
||||
const res = await this.client.proxy.guilds(guildId).channels.post({ body });
|
||||
await this.client.cache.channels?.setIfNI(CacheFrom.Rest, BaseChannel.__intent__(guildId), res.id, guildId, res);
|
||||
return channelFrom(res, this.client);
|
||||
return channelFrom(res, this.client) as SeyfertChannelMap[T];
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -22,7 +22,7 @@ import {
|
||||
type VoiceStateStructure,
|
||||
type WebhookStructure,
|
||||
} from '../client';
|
||||
import type { UsingClient } from '../commands';
|
||||
import type { SeyfertChannelMap, UsingClient } from '../commands';
|
||||
import {
|
||||
type EmojiResolvable,
|
||||
type MessageCreateBodyRequest,
|
||||
@ -167,8 +167,10 @@ export class BaseNoEditableChannel<T extends ChannelType> extends DiscordBase<AP
|
||||
list: (force = false): Promise<AllChannels[]> => ctx.client.guilds.channels.list(ctx.guildId, force),
|
||||
fetch: (id: string, force = false): Promise<AllChannels> =>
|
||||
ctx.client.guilds.channels.fetch(ctx.guildId, id, force),
|
||||
create: (body: RESTPostAPIGuildChannelJSONBody): Promise<AllChannels> =>
|
||||
ctx.client.guilds.channels.create(ctx.guildId, body),
|
||||
create: <T extends GuildChannelTypes = GuildChannelTypes>(
|
||||
body: RESTPostAPIGuildChannelJSONBody & { type: T },
|
||||
): Promise<SeyfertChannelMap[T]> =>
|
||||
ctx.client.guilds.channels.create(ctx.guildId, body as never) as Promise<SeyfertChannelMap[T]>,
|
||||
delete: (id: string, reason?: string): Promise<AllChannels> =>
|
||||
ctx.client.guilds.channels.delete(ctx.guildId, id, reason),
|
||||
edit: (id: string, body: RESTPatchAPIChannelJSONBody, reason?: string): Promise<AllChannels> =>
|
||||
@ -689,3 +691,15 @@ export type AllChannels =
|
||||
| NewsChannelStructure
|
||||
| DirectoryChannelStructure
|
||||
| StageChannelStructure;
|
||||
|
||||
export type GuildChannelTypes =
|
||||
| ChannelType.GuildAnnouncement
|
||||
| ChannelType.GuildVoice
|
||||
| ChannelType.GuildText
|
||||
| ChannelType.GuildStageVoice
|
||||
| ChannelType.GuildForum
|
||||
| ChannelType.GuildMedia
|
||||
| ChannelType.GuildCategory
|
||||
| ChannelType.AnnouncementThread
|
||||
| ChannelType.PrivateThread
|
||||
| ChannelType.PublicThread;
|
||||
|
Loading…
x
Reference in New Issue
Block a user