mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
templates
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { DiscordTemplate, Template } from "../../types/templates/template.ts";
|
||||
import { Template } from "../../types/templates/template.ts";
|
||||
import { Collection } from "../../util/collection.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { requireBotGuildPermissions } from "../../util/permissions.ts";
|
||||
import { snakeKeysToCamelCase } from "../../util/utils.ts";
|
||||
|
||||
/**
|
||||
* Returns an array of templates.
|
||||
@@ -12,15 +11,15 @@ import { snakeKeysToCamelCase } from "../../util/utils.ts";
|
||||
export async function getGuildTemplates(guildId: string) {
|
||||
await requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]);
|
||||
|
||||
const templates = (await rest.runMethod(
|
||||
const templates = await rest.runMethod<Template[]>(
|
||||
"get",
|
||||
endpoints.GUILD_TEMPLATES(guildId),
|
||||
)) as DiscordTemplate[];
|
||||
);
|
||||
|
||||
return new Collection(
|
||||
templates.map((template) => [
|
||||
template.code,
|
||||
snakeKeysToCamelCase<Template>(template),
|
||||
template,
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user