mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-02 04:56:07 +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... 🤓
|
||||
if (!this.ownerId) {
|
||||
return Promise.resolve(null);
|
||||
return null;
|
||||
}
|
||||
return this.members.fetch(this.ownerId, force);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ export class GuildEmoji extends DiscordBase {
|
||||
super(client, { ...data, id: data.id! });
|
||||
}
|
||||
|
||||
guild(force = false) {
|
||||
async guild(force = false) {
|
||||
if (!this.guildId) return;
|
||||
return this.client.guilds.fetch(this.guildId, force);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ export class GuildRole extends DiscordBase {
|
||||
this.permissions = new PermissionsBitField(BigInt(data.permissions));
|
||||
}
|
||||
|
||||
guild(force = false) {
|
||||
async guild(force = false) {
|
||||
if (!this.guildId) return;
|
||||
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);
|
||||
}
|
||||
|
||||
async fetch() {
|
||||
fetch() {
|
||||
return this.client.templates.fetch(this.sourceGuildId);
|
||||
}
|
||||
|
||||
|
@ -411,7 +411,7 @@ export class Interaction<
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,9 @@ import { Base } from './extra/Base';
|
||||
import type { UsingClient } from '../commands';
|
||||
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 {
|
||||
expiry: number;
|
||||
constructor(
|
||||
client: UsingClient,
|
||||
data: APIPoll,
|
||||
@ -15,9 +14,17 @@ export class Poll extends Base {
|
||||
readonly messageId: string,
|
||||
) {
|
||||
super(client);
|
||||
this.expiry = Date.parse(data.expiry);
|
||||
Object.assign(this, toCamelCase(data));
|
||||
}
|
||||
|
||||
get expiryTimestamp() {
|
||||
return Date.parse(this.expiry);
|
||||
}
|
||||
|
||||
get expiryAt() {
|
||||
return new Date(this.expiry);
|
||||
}
|
||||
|
||||
end() {
|
||||
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;
|
||||
return this.client.guilds.fetch(this.id, force);
|
||||
}
|
||||
|
||||
edit(body: RESTPatchAPIGuildStickerJSONBody, reason?: string) {
|
||||
async edit(body: RESTPatchAPIGuildStickerJSONBody, reason?: string) {
|
||||
if (!this.guildId) return;
|
||||
return this.client.guilds.stickers.edit(this.guildId, this.id, body, reason);
|
||||
}
|
||||
|
||||
fetch(force = false) {
|
||||
async fetch(force = false) {
|
||||
if (!this.guildId) return;
|
||||
return this.client.guilds.stickers.fetch(this.guildId, this.id, force);
|
||||
}
|
||||
|
||||
delete(reason?: string) {
|
||||
async delete(reason?: string) {
|
||||
if (!this.guildId) return;
|
||||
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);
|
||||
}
|
||||
|
||||
isMuted() {
|
||||
get isMuted() {
|
||||
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));
|
||||
}
|
||||
|
||||
async user(force?: boolean) {
|
||||
user(force?: boolean) {
|
||||
return this.client.users.fetch(this.userId, force);
|
||||
}
|
||||
|
||||
@ -35,17 +35,15 @@ export class VoiceState extends Base {
|
||||
}
|
||||
|
||||
async setMute(mute = !this.mute, reason?: string) {
|
||||
return this.client.members.edit(this.guildId, this.userId, { mute }, reason).then(member => {
|
||||
this.mute = mute;
|
||||
return member;
|
||||
});
|
||||
const member = await this.client.members.edit(this.guildId, this.userId, { mute }, reason);
|
||||
this.mute = mute;
|
||||
return member;
|
||||
}
|
||||
|
||||
async setDeaf(deaf = !this.deaf, reason?: string) {
|
||||
return this.client.members.edit(this.guildId, this.userId, { deaf }, reason).then(member => {
|
||||
this.deaf = deaf;
|
||||
return member;
|
||||
});
|
||||
const member = await this.client.members.edit(this.guildId, this.userId, { deaf }, reason);
|
||||
this.deaf = deaf;
|
||||
return member;
|
||||
}
|
||||
|
||||
async setSuppress(suppress = !this.suppress) {
|
||||
@ -66,14 +64,13 @@ export class VoiceState extends Base {
|
||||
this.requestToSpeakTimestamp = date;
|
||||
}
|
||||
|
||||
async disconnect(reason?: string) {
|
||||
disconnect(reason?: string) {
|
||||
return this.setChannel(null, reason);
|
||||
}
|
||||
|
||||
async setChannel(channel_id: null | string, reason?: string) {
|
||||
return this.client.members.edit(this.guildId, this.userId, { channel_id }, reason).then(member => {
|
||||
this.channelId = channel_id;
|
||||
return member;
|
||||
});
|
||||
const member = await this.client.members.edit(this.guildId, this.userId, { channel_id }, reason);
|
||||
this.channelId = channel_id;
|
||||
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.
|
||||
* @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;
|
||||
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.
|
||||
* @returns A promise that resolves to the fetched webhook data.
|
||||
*/
|
||||
async fetch() {
|
||||
fetch() {
|
||||
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.
|
||||
* @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 });
|
||||
}
|
||||
|
||||
|
@ -280,7 +280,7 @@ export class MessagesMethods extends DiscordBase {
|
||||
self: UsingClient,
|
||||
) {
|
||||
const poll = (body as MessageCreateBodyRequest).poll;
|
||||
const allow = {
|
||||
const payload = {
|
||||
allowed_mentions: self.options?.allowedMentions,
|
||||
...body,
|
||||
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,
|
||||
};
|
||||
|
||||
if ('attachment' in body) {
|
||||
allow.attachments =
|
||||
if ('attachments' in body) {
|
||||
payload.attachments =
|
||||
body.attachments?.map((x, i) => ({
|
||||
id: i,
|
||||
...resolveAttachment(x),
|
||||
})) ?? undefined;
|
||||
} else if (files?.length) {
|
||||
allow.attachments = files?.map((x, id) => ({
|
||||
payload.attachments = files?.map((x, id) => ({
|
||||
id,
|
||||
filename: x.name,
|
||||
})) as RESTAPIAttachment[];
|
||||
}
|
||||
return allow as unknown as T;
|
||||
return payload as T;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user