mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-02 04:56:07 +00:00
fix: some shorters doesn't return structs (#183)
This commit is contained in:
parent
c573ca9909
commit
38ef5d91cf
@ -19,6 +19,7 @@ import {
|
||||
GuildMember,
|
||||
Sticker,
|
||||
type CreateStickerBodyRequest,
|
||||
AutoModerationRule,
|
||||
} from '../../structures';
|
||||
import channelFrom from '../../structures/channels';
|
||||
import { BaseShorter } from './base';
|
||||
@ -197,7 +198,11 @@ export class GuildShorter extends BaseShorter {
|
||||
* @param guildId The ID of the guild.
|
||||
* @returns A Promise that resolves to an array of auto-moderation rules.
|
||||
*/
|
||||
list: (guildId: string) => this.client.proxy.guilds(guildId)['auto-moderation'].rules.get(),
|
||||
list: (guildId: string) =>
|
||||
this.client.proxy
|
||||
.guilds(guildId)
|
||||
['auto-moderation'].rules.get()
|
||||
.then(rules => rules.map(rule => new AutoModerationRule(this.client, rule))),
|
||||
|
||||
/**
|
||||
* Creates a new auto-moderation rule in the guild.
|
||||
@ -206,7 +211,10 @@ export class GuildShorter extends BaseShorter {
|
||||
* @returns A Promise that resolves to the created auto-moderation rule.
|
||||
*/
|
||||
create: (guildId: string, body: RESTPostAPIAutoModerationRuleJSONBody) =>
|
||||
this.client.proxy.guilds(guildId)['auto-moderation'].rules.post({ body }),
|
||||
this.client.proxy
|
||||
.guilds(guildId)
|
||||
['auto-moderation'].rules.post({ body })
|
||||
.then(rule => new AutoModerationRule(this.client, rule)),
|
||||
|
||||
/**
|
||||
* Deletes an auto-moderation rule from the guild.
|
||||
@ -226,7 +234,11 @@ export class GuildShorter extends BaseShorter {
|
||||
* @returns A Promise that resolves to the fetched auto-moderation rule.
|
||||
*/
|
||||
fetch: (guildId: string, ruleId: string) => {
|
||||
return this.client.proxy.guilds(guildId)['auto-moderation'].rules(ruleId).get();
|
||||
return this.client.proxy
|
||||
.guilds(guildId)
|
||||
['auto-moderation'].rules(ruleId)
|
||||
.get()
|
||||
.then(rule => new AutoModerationRule(this.client, rule));
|
||||
},
|
||||
|
||||
/**
|
||||
@ -243,7 +255,11 @@ export class GuildShorter extends BaseShorter {
|
||||
body: ObjectToLower<RESTPatchAPIAutoModerationRuleJSONBody>,
|
||||
reason?: string,
|
||||
) => {
|
||||
return this.client.proxy.guilds(guildId)['auto-moderation'].rules(ruleId).patch({ body, reason });
|
||||
return this.client.proxy
|
||||
.guilds(guildId)
|
||||
['auto-moderation'].rules(ruleId)
|
||||
.patch({ body, reason })
|
||||
.then(rule => new AutoModerationRule(this.client, rule));
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -15,11 +15,10 @@ export class RoleShorter extends BaseShorter {
|
||||
* @param reason The reason for creating the role.
|
||||
* @returns A Promise that resolves when the role is created.
|
||||
*/
|
||||
create(guildId: string, body: RESTPostAPIGuildRoleJSONBody, reason?: string) {
|
||||
return this.client.proxy
|
||||
.guilds(guildId)
|
||||
.roles.post({ body, reason })
|
||||
.then(res => this.client.cache.roles?.setIfNI('Guilds', res.id, guildId, res));
|
||||
async create(guildId: string, body: RESTPostAPIGuildRoleJSONBody, reason?: string) {
|
||||
const res = await this.client.proxy.guilds(guildId).roles.post({ body, reason });
|
||||
await this.client.cache.roles?.setIfNI('Guilds', res.id, guildId, res);
|
||||
return new GuildRole(this.client, res, guildId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,12 +51,10 @@ export class RoleShorter extends BaseShorter {
|
||||
* @param reason The reason for editing the role.
|
||||
* @returns A Promise that resolves when the role is edited.
|
||||
*/
|
||||
edit(guildId: string, roleId: string, body: RESTPatchAPIGuildRoleJSONBody, reason?: string) {
|
||||
return this.client.proxy
|
||||
.guilds(guildId)
|
||||
.roles(roleId)
|
||||
.patch({ body, reason })
|
||||
.then(res => this.client.cache.roles?.setIfNI('Guilds', roleId, guildId, res));
|
||||
async edit(guildId: string, roleId: string, body: RESTPatchAPIGuildRoleJSONBody, reason?: string) {
|
||||
const res = await this.client.proxy.guilds(guildId).roles(roleId).patch({ body, reason });
|
||||
await this.client.cache.roles?.setIfNI('Guilds', roleId, guildId, res);
|
||||
return new GuildRole(this.client, res, guildId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,12 +64,10 @@ export class RoleShorter extends BaseShorter {
|
||||
* @param reason The reason for deleting the role.
|
||||
* @returns A Promise that resolves when the role is deleted.
|
||||
*/
|
||||
delete(guildId: string, roleId: string, reason?: string) {
|
||||
return this.client.proxy
|
||||
.guilds(guildId)
|
||||
.roles(roleId)
|
||||
.delete({ reason })
|
||||
.then(() => this.client.cache.roles?.removeIfNI('Guilds', roleId, guildId));
|
||||
async delete(guildId: string, roleId: string, reason?: string) {
|
||||
const res = await this.client.proxy.guilds(guildId).roles(roleId).delete({ reason });
|
||||
this.client.cache.roles?.removeIfNI('Guilds', roleId, guildId);
|
||||
return new GuildRole(this.client, res, guildId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,28 +1,50 @@
|
||||
import type { RESTPatchAPIGuildTemplateJSONBody, RESTPostAPIGuildTemplatesJSONBody } from 'discord-api-types/v10';
|
||||
import { BaseShorter } from './base';
|
||||
import { GuildTemplate } from '../..';
|
||||
|
||||
export class TemplateShorter extends BaseShorter {
|
||||
fetch(code: string) {
|
||||
return this.client.proxy.guilds.templates(code).get();
|
||||
return this.client.proxy.guilds
|
||||
.templates(code)
|
||||
.get()
|
||||
.then(template => new GuildTemplate(this.client, template));
|
||||
}
|
||||
|
||||
list(guildId: string) {
|
||||
return this.client.proxy.guilds(guildId).templates.get();
|
||||
return this.client.proxy
|
||||
.guilds(guildId)
|
||||
.templates.get()
|
||||
.then(list => list.map(template => new GuildTemplate(this.client, template)));
|
||||
}
|
||||
|
||||
create(guildId: string, body: RESTPostAPIGuildTemplatesJSONBody) {
|
||||
return this.client.proxy.guilds(guildId).templates.post({ body });
|
||||
return this.client.proxy
|
||||
.guilds(guildId)
|
||||
.templates.post({ body })
|
||||
.then(template => new GuildTemplate(this.client, template));
|
||||
}
|
||||
|
||||
sync(guildId: string, code: string) {
|
||||
return this.client.proxy.guilds(guildId).templates(code).put({});
|
||||
return this.client.proxy
|
||||
.guilds(guildId)
|
||||
.templates(code)
|
||||
.put({})
|
||||
.then(template => new GuildTemplate(this.client, template));
|
||||
}
|
||||
|
||||
edit(guildId: string, code: string, body: RESTPatchAPIGuildTemplateJSONBody) {
|
||||
return this.client.proxy.guilds(guildId).templates(code).patch({ body });
|
||||
return this.client.proxy
|
||||
.guilds(guildId)
|
||||
.templates(code)
|
||||
.patch({ body })
|
||||
.then(template => new GuildTemplate(this.client, template));
|
||||
}
|
||||
|
||||
delete(guildId: string, code: string) {
|
||||
return this.client.proxy.guilds(guildId).templates(code).delete();
|
||||
return this.client.proxy
|
||||
.guilds(guildId)
|
||||
.templates(code)
|
||||
.delete()
|
||||
.then(template => new GuildTemplate(this.client, template));
|
||||
}
|
||||
}
|
||||
|
@ -47,9 +47,15 @@ export class WebhookShorter extends BaseShorter {
|
||||
options: WebhookShorterOptionalParams,
|
||||
) {
|
||||
if (options.token) {
|
||||
return this.client.proxy.webhooks(webhookId)(options.token).patch({ body, reason: options.reason, auth: false });
|
||||
return this.client.proxy
|
||||
.webhooks(webhookId)(options.token)
|
||||
.patch({ body, reason: options.reason, auth: false })
|
||||
.then(webhook => new Webhook(this.client, webhook));
|
||||
}
|
||||
return this.client.proxy.webhooks(webhookId).patch({ body, reason: options.reason });
|
||||
return this.client.proxy
|
||||
.webhooks(webhookId)
|
||||
.patch({ body, reason: options.reason })
|
||||
.then(webhook => new Webhook(this.client, webhook));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user