mirror of
https://github.com/spacebarchat/server.git
synced 2026-06-06 15:31:42 +00:00
a lot of small fixes
This commit is contained in:
@@ -322,6 +322,7 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> {
|
||||
|
||||
const message = Message.create({
|
||||
...opts,
|
||||
message_reference: opts.message_reference ?? undefined,
|
||||
poll: opts.poll,
|
||||
sticker_items: stickers,
|
||||
guild_id: channel.guild_id,
|
||||
@@ -332,8 +333,8 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> {
|
||||
type: opts.type ?? 0,
|
||||
mentions: [],
|
||||
components: opts.components ?? undefined, // Fix Discord-Go?
|
||||
message_reference: opts.message_reference ?? undefined,
|
||||
});
|
||||
message.channel = channel;
|
||||
const batchId = `CLOUD_${message.author_id}_${randomString(128)}`;
|
||||
|
||||
if (opts.author_id) {
|
||||
@@ -463,6 +464,7 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> {
|
||||
permission.hasThrow("SEND_MESSAGES");
|
||||
if (permission.cache.member) {
|
||||
message.member = permission.cache.member;
|
||||
console.log(message.member.flags);
|
||||
}
|
||||
|
||||
if (opts.tts) permission.hasThrow("SEND_TTS_MESSAGES");
|
||||
|
||||
@@ -113,6 +113,7 @@ export function route(opts: RouteOptions) {
|
||||
if (validate && !ignoredRequestSchemas.includes(opts.requestBody!)) {
|
||||
const valid = validate(req.body);
|
||||
if (!valid) {
|
||||
console.log(req.body);
|
||||
const fields: Record<string, { code?: string; message: string }> = {};
|
||||
validate.errors?.forEach(
|
||||
(x) =>
|
||||
|
||||
@@ -780,11 +780,12 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
||||
|
||||
// If we're a bot user, send GUILD_CREATE for each unavailable guild
|
||||
// TODO: check if bot has permission to view some of these based on intents (i.e. GUILD_MEMBERS, GUILD_PRESENCES, GUILD_VOICE_STATES)
|
||||
|
||||
await Promise.all(
|
||||
pending_guilds.map((x) => {
|
||||
//Even with the GUILD_MEMBERS intent, the bot always receives just itself as the guild members
|
||||
const botMemberObject = members.find((member) => member.guild_id === x.id);
|
||||
|
||||
//Object.assign(x, { threads: [] });
|
||||
return Send(this, {
|
||||
op: OPCODES.Dispatch,
|
||||
t: EVENTEnum.GuildCreate,
|
||||
|
||||
@@ -713,6 +713,20 @@ export class Channel extends BaseClass {
|
||||
rate_limit_per_user: this.rate_limit_per_user || undefined,
|
||||
owner_id: this.owner_id || undefined,
|
||||
...(this.isThread() && this.thread_members ? { member_ids_preview: this.thread_members.map((_) => _.member.id) } : {}),
|
||||
default_auto_archive_duration: this.default_auto_archive_duration ?? undefined,
|
||||
retention_policy_id: undefined,
|
||||
thread_metadata: this.thread_metadata
|
||||
? {
|
||||
...this.thread_metadata,
|
||||
archive_timestamp: new Date(this.thread_metadata.archive_timestamp).toISOString().replace("Z", "+00:00"),
|
||||
create_timestamp: new Date(this.thread_metadata.create_timestamp).toISOString().replace("Z", "+00:00"),
|
||||
}
|
||||
: undefined,
|
||||
member_count: this.member_count ?? undefined,
|
||||
message_count: this.message_count ?? undefined,
|
||||
total_message_sent: this.total_message_sent ?? undefined,
|
||||
applied_tags: this.applied_tags ?? undefined,
|
||||
permission_overwrites: this.isThread() ? undefined : this.permission_overwrites,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -480,6 +480,10 @@ export class Guild extends BaseClass {
|
||||
discovery_weight: undefined,
|
||||
discovery_excluded: undefined,
|
||||
parent: undefined,
|
||||
primary_category_id: undefined,
|
||||
nsfw: undefined,
|
||||
template_id: undefined,
|
||||
presence_count: undefined,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,6 +259,7 @@ export class Message extends BaseClass {
|
||||
toJSON(shallow = false): Message {
|
||||
return {
|
||||
...this,
|
||||
channel: undefined,
|
||||
author_id: undefined,
|
||||
member_id: undefined,
|
||||
webhook_id: this.webhook_id ?? undefined,
|
||||
|
||||
@@ -10,4 +10,4 @@ export class MemberFlags1772404321400 implements MigrationInterface {
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "members" DROP COLUMN "flags"`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class MemberFlags1772403866471 implements MigrationInterface {
|
||||
name = "MemberFlags1772403866471";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "members" ADD "flags" integer NOT NULL DEFAULT '0'`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "members" DROP COLUMN "flags"`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user