mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-04 14:06:07 +00:00
fix(webhook handling) closes #24
This commit is contained in:
parent
e170994ad3
commit
9a5a25c2d5
@ -83,7 +83,10 @@ export class Message implements Model {
|
|||||||
this.guildId = data.guild_id;
|
this.guildId = data.guild_id;
|
||||||
this.applicationId = data.application_id;
|
this.applicationId = data.application_id;
|
||||||
|
|
||||||
|
if (!data.webhook_id) {
|
||||||
this.author = new User(session, data.author);
|
this.author = new User(session, data.author);
|
||||||
|
}
|
||||||
|
|
||||||
this.flags = data.flags;
|
this.flags = data.flags;
|
||||||
this.pinned = !!data.pinned;
|
this.pinned = !!data.pinned;
|
||||||
this.tts = !!data.tts;
|
this.tts = !!data.tts;
|
||||||
@ -103,19 +106,9 @@ export class Message implements Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// webhook handling
|
// webhook handling
|
||||||
if (data.author.discriminator === "0000") {
|
if (data.webhook_id && data.author.discriminator === "0000") {
|
||||||
this.webhook = {
|
this.webhook = {
|
||||||
id: data.author.id,
|
id: data.webhook_id!,
|
||||||
username: data.author.username,
|
|
||||||
discriminator: data.author.discriminator,
|
|
||||||
avatar: data.author.avatar ? iconHashToBigInt(data.author.avatar) : undefined,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// webhook handling
|
|
||||||
if (data.author && data.author.discriminator === "0000") {
|
|
||||||
this.webhook = {
|
|
||||||
id: data.author.id,
|
|
||||||
username: data.author.username,
|
username: data.author.username,
|
||||||
discriminator: data.author.discriminator,
|
discriminator: data.author.discriminator,
|
||||||
avatar: data.author.avatar ? iconHashToBigInt(data.author.avatar) : undefined,
|
avatar: data.author.avatar ? iconHashToBigInt(data.author.avatar) : undefined,
|
||||||
@ -123,7 +116,6 @@ export class Message implements Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// user is always null on MessageCreate and its replaced with author
|
// user is always null on MessageCreate and its replaced with author
|
||||||
|
|
||||||
if (data.guild_id && data.member && !this.isWebhookMessage()) {
|
if (data.guild_id && data.member && !this.isWebhookMessage()) {
|
||||||
this.member = new Member(session, { ...data.member, user: data.author }, data.guild_id);
|
this.member = new Member(session, { ...data.member, user: data.author }, data.guild_id);
|
||||||
}
|
}
|
||||||
@ -145,7 +137,7 @@ export class Message implements Model {
|
|||||||
channelId: Snowflake;
|
channelId: Snowflake;
|
||||||
guildId?: Snowflake;
|
guildId?: Snowflake;
|
||||||
applicationId?: Snowflake;
|
applicationId?: Snowflake;
|
||||||
author: User;
|
author!: User;
|
||||||
flags?: MessageFlags;
|
flags?: MessageFlags;
|
||||||
pinned: boolean;
|
pinned: boolean;
|
||||||
tts: boolean;
|
tts: boolean;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user