🐛 fix guild create icon
This commit is contained in:
parent
859fdd679b
commit
181afe7e09
@ -1,6 +1,6 @@
|
|||||||
import { Router, Request, Response } from "express";
|
import { Router, Request, Response } from "express";
|
||||||
import { Role, Guild, Snowflake, Config, User, Member, Channel } from "@fosscord/util";
|
import { Role, Guild, Snowflake, Config, User, Member, Channel } from "@fosscord/util";
|
||||||
import { route } from "@fosscord/api";
|
import { handleFile, route } from "@fosscord/api";
|
||||||
import { DiscordApiErrors } from "@fosscord/util";
|
import { DiscordApiErrors } from "@fosscord/util";
|
||||||
import { ChannelModifySchema } from "../channels/#channel_id";
|
import { ChannelModifySchema } from "../channels/#channel_id";
|
||||||
|
|
||||||
@ -34,6 +34,7 @@ router.post("/", route({ body: "GuildCreateSchema" }), async (req: Request, res:
|
|||||||
|
|
||||||
await Guild.insert({
|
await Guild.insert({
|
||||||
name: body.name,
|
name: body.name,
|
||||||
|
icon: await handleFile(`/icons/${guild_id}`, body.icon as string),
|
||||||
region: Config.get().regions.default,
|
region: Config.get().regions.default,
|
||||||
owner_id: req.user_id,
|
owner_id: req.user_id,
|
||||||
afk_timeout: 300,
|
afk_timeout: 300,
|
||||||
|
@ -42,9 +42,9 @@ export async function handleFile(path: string, body?: string): Promise<string |
|
|||||||
export async function deleteFile(path: string) {
|
export async function deleteFile(path: string) {
|
||||||
const response = await fetch(`${Config.get().cdn.endpoint || "http://localhost:3003"}${path}`, {
|
const response = await fetch(`${Config.get().cdn.endpoint || "http://localhost:3003"}${path}`, {
|
||||||
headers: {
|
headers: {
|
||||||
signature: Config.get().security.requestSignature,
|
signature: Config.get().security.requestSignature
|
||||||
},
|
},
|
||||||
method: "DELETE",
|
method: "DELETE"
|
||||||
});
|
});
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user