mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-17 19:58:18 +00:00
types: fix new types issues (#829)
* feat: add tests for deleting channel overwrites * fix: typings
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { structures } from "../../structures/mod.ts";
|
||||
import { DiscordTemplate } from "../../types/templates/template.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { requireBotGuildPermissions } from "../../util/permissions.ts";
|
||||
|
||||
@@ -27,7 +28,7 @@ export async function createGuildTemplate(
|
||||
"post",
|
||||
endpoints.GUILD_TEMPLATES(guildId),
|
||||
data,
|
||||
)) as GuildTemplate;
|
||||
)) as DiscordTemplate;
|
||||
|
||||
return structures.createTemplateStruct(template);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { structures } from "../../structures/mod.ts";
|
||||
import { DiscordTemplate } from "../../types/templates/template.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { requireBotGuildPermissions } from "../../util/permissions.ts";
|
||||
|
||||
@@ -16,7 +17,7 @@ export async function deleteGuildTemplate(
|
||||
const deletedTemplate = (await rest.runMethod(
|
||||
"delete",
|
||||
`${endpoints.GUILD_TEMPLATES(guildId)}/${templateCode}`,
|
||||
)) as GuildTemplate;
|
||||
)) as DiscordTemplate;
|
||||
|
||||
return structures.createTemplateStruct(deletedTemplate);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { structures } from "../../structures/mod.ts";
|
||||
import { DiscordTemplate } from "../../types/templates/template.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { requireBotGuildPermissions } from "../../util/permissions.ts";
|
||||
|
||||
@@ -26,7 +27,7 @@ export async function editGuildTemplate(
|
||||
"patch",
|
||||
`${endpoints.GUILD_TEMPLATES(guildId)}/${templateCode}`,
|
||||
data,
|
||||
)) as GuildTemplate;
|
||||
)) as DiscordTemplate;
|
||||
|
||||
return structures.createTemplateStruct(template);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { rest } from "../../rest/rest.ts";
|
||||
import { structures } from "../../structures/mod.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { requireBotGuildPermissions } from "../../util/permissions.ts";
|
||||
import { DiscordTemplate } from "../../types/templates/template.ts";
|
||||
|
||||
/**
|
||||
* Returns an array of templates.
|
||||
@@ -12,8 +13,8 @@ export async function getGuildTemplates(guildId: string) {
|
||||
|
||||
const templates = (await rest.runMethod(
|
||||
"get",
|
||||
endpoints.GUILD_TEMPLATES(guildId),
|
||||
)) as GuildTemplate[];
|
||||
endpoints.GUILD_TEMPLATES(guildId)
|
||||
)) as DiscordTemplate[];
|
||||
|
||||
return templates.map((template) => structures.createTemplateStruct(template));
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { structures } from "../../structures/mod.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { DiscordTemplate } from "../../types/templates/template.ts";
|
||||
|
||||
/** Returns the guild template if it exists */
|
||||
export async function getTemplate(templateCode: string) {
|
||||
const result = (await rest.runMethod(
|
||||
"get",
|
||||
endpoints.GUILD_TEMPLATE(templateCode),
|
||||
) as GuildTemplate);
|
||||
) as DiscordTemplate);
|
||||
const template = await structures.createTemplateStruct(result);
|
||||
|
||||
return template;
|
||||
|
||||
@@ -2,6 +2,7 @@ import { rest } from "../../rest/rest.ts";
|
||||
import { structures } from "../../structures/mod.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { requireBotGuildPermissions } from "../../util/permissions.ts";
|
||||
import { DiscordTemplate } from "../../types/templates/template.ts";
|
||||
|
||||
/**
|
||||
* Syncs the template to the guild's current state.
|
||||
@@ -13,7 +14,7 @@ export async function syncGuildTemplate(guildId: string, templateCode: string) {
|
||||
const template = (await rest.runMethod(
|
||||
"put",
|
||||
`${endpoints.GUILD_TEMPLATES(guildId)}/${templateCode}`,
|
||||
)) as GuildTemplate;
|
||||
)) as DiscordTemplate;
|
||||
|
||||
return structures.createTemplateStruct(template);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user