mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-04 22:16:08 +00:00
fix: socramcode
This commit is contained in:
parent
f487072ced
commit
e6f94d409d
@ -61,10 +61,10 @@ export class Guild<State extends StructStates = 'api'> extends (BaseGuild as unk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchOwner(force = false) {
|
async fetchOwner(force = false) {
|
||||||
// For no reason, discord has some guilds without owner... 🤓
|
// For no reason, discord has some guilds without owner... 🤓
|
||||||
if (!this.ownerId) {
|
if (!this.ownerId) {
|
||||||
return Promise.resolve(null);
|
return null;
|
||||||
}
|
}
|
||||||
return this.members.fetch(this.ownerId, force);
|
return this.members.fetch(this.ownerId, force);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ export class GuildEmoji extends DiscordBase {
|
|||||||
super(client, { ...data, id: data.id! });
|
super(client, { ...data, id: data.id! });
|
||||||
}
|
}
|
||||||
|
|
||||||
guild(force = false) {
|
async guild(force = false) {
|
||||||
if (!this.guildId) return;
|
if (!this.guildId) return;
|
||||||
return this.client.guilds.fetch(this.guildId, force);
|
return this.client.guilds.fetch(this.guildId, force);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ export class GuildRole extends DiscordBase {
|
|||||||
this.permissions = new PermissionsBitField(BigInt(data.permissions));
|
this.permissions = new PermissionsBitField(BigInt(data.permissions));
|
||||||
}
|
}
|
||||||
|
|
||||||
guild(force = false) {
|
async guild(force = false) {
|
||||||
if (!this.guildId) return;
|
if (!this.guildId) return;
|
||||||
return this.client.guilds.fetch(this.guildId, force);
|
return this.client.guilds.fetch(this.guildId, force);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ export class GuildTemplate extends Base {
|
|||||||
return this.client.guilds.fetch(this.sourceGuildId, force);
|
return this.client.guilds.fetch(this.sourceGuildId, force);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetch() {
|
fetch() {
|
||||||
return this.client.templates.fetch(this.sourceGuildId);
|
return this.client.templates.fetch(this.sourceGuildId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,7 +411,7 @@ export class Interaction<
|
|||||||
return this.client.interactions.deleteResponse(this.id, this.token, messageId);
|
return this.client.interactions.deleteResponse(this.id, this.token, messageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
async followup(body: MessageWebhookCreateBodyRequest) {
|
followup(body: MessageWebhookCreateBodyRequest) {
|
||||||
return this.client.interactions.followup(this.token, body);
|
return this.client.interactions.followup(this.token, body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,9 @@ import { Base } from './extra/Base';
|
|||||||
import type { UsingClient } from '../commands';
|
import type { UsingClient } from '../commands';
|
||||||
import type { ValidAnswerId } from '../api/Routes/channels';
|
import type { ValidAnswerId } from '../api/Routes/channels';
|
||||||
|
|
||||||
export interface Poll extends ObjectToLower<Omit<APIPoll, 'expiry'>> {}
|
export interface Poll extends ObjectToLower<APIPoll> {}
|
||||||
|
|
||||||
export class Poll extends Base {
|
export class Poll extends Base {
|
||||||
expiry: number;
|
|
||||||
constructor(
|
constructor(
|
||||||
client: UsingClient,
|
client: UsingClient,
|
||||||
data: APIPoll,
|
data: APIPoll,
|
||||||
@ -15,9 +14,17 @@ export class Poll extends Base {
|
|||||||
readonly messageId: string,
|
readonly messageId: string,
|
||||||
) {
|
) {
|
||||||
super(client);
|
super(client);
|
||||||
this.expiry = Date.parse(data.expiry);
|
|
||||||
Object.assign(this, toCamelCase(data));
|
Object.assign(this, toCamelCase(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get expiryTimestamp() {
|
||||||
|
return Date.parse(this.expiry);
|
||||||
|
}
|
||||||
|
|
||||||
|
get expiryAt() {
|
||||||
|
return new Date(this.expiry);
|
||||||
|
}
|
||||||
|
|
||||||
end() {
|
end() {
|
||||||
return this.client.messages.endPoll(this.channelId, this.messageId);
|
return this.client.messages.endPoll(this.channelId, this.messageId);
|
||||||
}
|
}
|
||||||
|
@ -16,22 +16,22 @@ export class Sticker extends DiscordBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
guild(force = false) {
|
async guild(force = false) {
|
||||||
if (!this.guildId) return;
|
if (!this.guildId) return;
|
||||||
return this.client.guilds.fetch(this.id, force);
|
return this.client.guilds.fetch(this.id, force);
|
||||||
}
|
}
|
||||||
|
|
||||||
edit(body: RESTPatchAPIGuildStickerJSONBody, reason?: string) {
|
async edit(body: RESTPatchAPIGuildStickerJSONBody, reason?: string) {
|
||||||
if (!this.guildId) return;
|
if (!this.guildId) return;
|
||||||
return this.client.guilds.stickers.edit(this.guildId, this.id, body, reason);
|
return this.client.guilds.stickers.edit(this.guildId, this.id, body, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch(force = false) {
|
async fetch(force = false) {
|
||||||
if (!this.guildId) return;
|
if (!this.guildId) return;
|
||||||
return this.client.guilds.stickers.fetch(this.guildId, this.id, force);
|
return this.client.guilds.stickers.fetch(this.guildId, this.id, force);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(reason?: string) {
|
async delete(reason?: string) {
|
||||||
if (!this.guildId) return;
|
if (!this.guildId) return;
|
||||||
return this.client.guilds.stickers.delete(this.guildId, this.id, reason);
|
return this.client.guilds.stickers.delete(this.guildId, this.id, reason);
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ export class VoiceState extends Base {
|
|||||||
this.withMember = Transformers.GuildMember(client, member, member.user, data.guild_id);
|
this.withMember = Transformers.GuildMember(client, member, member.user, data.guild_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
isMuted() {
|
get isMuted() {
|
||||||
return this.mute || this.selfMute;
|
return this.mute || this.selfMute;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ export class VoiceState extends Base {
|
|||||||
return (this.withMember = await this.client.members.fetch(this.guildId, this.userId, force));
|
return (this.withMember = await this.client.members.fetch(this.guildId, this.userId, force));
|
||||||
}
|
}
|
||||||
|
|
||||||
async user(force?: boolean) {
|
user(force?: boolean) {
|
||||||
return this.client.users.fetch(this.userId, force);
|
return this.client.users.fetch(this.userId, force);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,17 +35,15 @@ export class VoiceState extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async setMute(mute = !this.mute, reason?: string) {
|
async setMute(mute = !this.mute, reason?: string) {
|
||||||
return this.client.members.edit(this.guildId, this.userId, { mute }, reason).then(member => {
|
const member = await this.client.members.edit(this.guildId, this.userId, { mute }, reason);
|
||||||
this.mute = mute;
|
this.mute = mute;
|
||||||
return member;
|
return member;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async setDeaf(deaf = !this.deaf, reason?: string) {
|
async setDeaf(deaf = !this.deaf, reason?: string) {
|
||||||
return this.client.members.edit(this.guildId, this.userId, { deaf }, reason).then(member => {
|
const member = await this.client.members.edit(this.guildId, this.userId, { deaf }, reason);
|
||||||
this.deaf = deaf;
|
this.deaf = deaf;
|
||||||
return member;
|
return member;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async setSuppress(suppress = !this.suppress) {
|
async setSuppress(suppress = !this.suppress) {
|
||||||
@ -66,14 +64,13 @@ export class VoiceState extends Base {
|
|||||||
this.requestToSpeakTimestamp = date;
|
this.requestToSpeakTimestamp = date;
|
||||||
}
|
}
|
||||||
|
|
||||||
async disconnect(reason?: string) {
|
disconnect(reason?: string) {
|
||||||
return this.setChannel(null, reason);
|
return this.setChannel(null, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
async setChannel(channel_id: null | string, reason?: string) {
|
async setChannel(channel_id: null | string, reason?: string) {
|
||||||
return this.client.members.edit(this.guildId, this.userId, { channel_id }, reason).then(member => {
|
const member = await this.client.members.edit(this.guildId, this.userId, { channel_id }, reason);
|
||||||
this.channelId = channel_id;
|
this.channelId = channel_id;
|
||||||
return member;
|
return member;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ export class Webhook extends DiscordBase {
|
|||||||
* @param force Whether to force fetching the guild even if it's already cached.
|
* @param force Whether to force fetching the guild even if it's already cached.
|
||||||
* @returns A promise that resolves to the guild associated with the webhook, or undefined if not applicable.
|
* @returns A promise that resolves to the guild associated with the webhook, or undefined if not applicable.
|
||||||
*/
|
*/
|
||||||
guild(force = false) {
|
async guild(force = false) {
|
||||||
if (!this.sourceGuild?.id) return;
|
if (!this.sourceGuild?.id) return;
|
||||||
return this.client.guilds.fetch(this.sourceGuild.id, force);
|
return this.client.guilds.fetch(this.sourceGuild.id, force);
|
||||||
}
|
}
|
||||||
@ -90,7 +90,7 @@ export class Webhook extends DiscordBase {
|
|||||||
* Fetches the webhook data from the Discord API.
|
* Fetches the webhook data from the Discord API.
|
||||||
* @returns A promise that resolves to the fetched webhook data.
|
* @returns A promise that resolves to the fetched webhook data.
|
||||||
*/
|
*/
|
||||||
async fetch() {
|
fetch() {
|
||||||
return this.client.webhooks.fetch(this.id, this.token);
|
return this.client.webhooks.fetch(this.id, this.token);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ export class Webhook extends DiscordBase {
|
|||||||
* @param reason The reason for editing the webhook.
|
* @param reason The reason for editing the webhook.
|
||||||
* @returns A promise that resolves when the webhook is successfully edited.
|
* @returns A promise that resolves when the webhook is successfully edited.
|
||||||
*/
|
*/
|
||||||
async edit(body: RESTPatchAPIWebhookJSONBody | RESTPatchAPIWebhookWithTokenJSONBody, reason?: string) {
|
edit(body: RESTPatchAPIWebhookJSONBody | RESTPatchAPIWebhookWithTokenJSONBody, reason?: string) {
|
||||||
return this.client.webhooks.edit(this.id, body, { reason, token: this.token });
|
return this.client.webhooks.edit(this.id, body, { reason, token: this.token });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,7 +280,7 @@ export class MessagesMethods extends DiscordBase {
|
|||||||
self: UsingClient,
|
self: UsingClient,
|
||||||
) {
|
) {
|
||||||
const poll = (body as MessageCreateBodyRequest).poll;
|
const poll = (body as MessageCreateBodyRequest).poll;
|
||||||
const allow = {
|
const payload = {
|
||||||
allowed_mentions: self.options?.allowedMentions,
|
allowed_mentions: self.options?.allowedMentions,
|
||||||
...body,
|
...body,
|
||||||
components: body.components?.map(x => (x instanceof ActionRow ? x.toJSON() : x)) ?? undefined,
|
components: body.components?.map(x => (x instanceof ActionRow ? x.toJSON() : x)) ?? undefined,
|
||||||
@ -288,19 +288,19 @@ export class MessagesMethods extends DiscordBase {
|
|||||||
poll: poll ? (poll instanceof PollBuilder ? poll.toJSON() : poll) : undefined,
|
poll: poll ? (poll instanceof PollBuilder ? poll.toJSON() : poll) : undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
if ('attachment' in body) {
|
if ('attachments' in body) {
|
||||||
allow.attachments =
|
payload.attachments =
|
||||||
body.attachments?.map((x, i) => ({
|
body.attachments?.map((x, i) => ({
|
||||||
id: i,
|
id: i,
|
||||||
...resolveAttachment(x),
|
...resolveAttachment(x),
|
||||||
})) ?? undefined;
|
})) ?? undefined;
|
||||||
} else if (files?.length) {
|
} else if (files?.length) {
|
||||||
allow.attachments = files?.map((x, id) => ({
|
payload.attachments = files?.map((x, id) => ({
|
||||||
id,
|
id,
|
||||||
filename: x.name,
|
filename: x.name,
|
||||||
})) as RESTAPIAttachment[];
|
})) as RESTAPIAttachment[];
|
||||||
}
|
}
|
||||||
return allow as unknown as T;
|
return payload as T;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user