mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 19:28:17 +00:00
some moar fixes lol
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { DiscordUser } from "../../types/users/user.ts";
|
||||
import { User } from "../../types/users/user.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { snakeKeysToCamelCase } from "../../util/utils.ts";
|
||||
|
||||
/** This function will return the raw user payload in the rare cases you need to fetch a user directly from the API. */
|
||||
export async function getUser(userId: string) {
|
||||
const result = await rest.runMethod("get", endpoints.USER(userId));
|
||||
const result: User = await rest.runMethod("get", endpoints.USER(userId));
|
||||
|
||||
return result as UserPayload;
|
||||
return snakeKeysToCamelCase<DiscordUser>(result);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { structures } from "../../structures/mod.ts";
|
||||
import { CreateGuildRole } from "../../types/guilds/create_guild_role.ts";
|
||||
import { DiscordRole } from "../../types/permissions/role.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import {
|
||||
calculateBits,
|
||||
@@ -10,19 +12,25 @@ import {
|
||||
/** Create a new role for the guild. Requires the MANAGE_ROLES permission. */
|
||||
export async function createRole(
|
||||
guildId: string,
|
||||
options: CreateRoleOptions,
|
||||
options: CreateGuildRole,
|
||||
reason?: string,
|
||||
) {
|
||||
await requireBotGuildPermissions(guildId, ["MANAGE_ROLES"]);
|
||||
|
||||
const result = await rest.runMethod("post", endpoints.GUILD_ROLES(guildId), {
|
||||
...options,
|
||||
permissions: calculateBits(options?.permissions || []),
|
||||
reason,
|
||||
});
|
||||
const result: DiscordRole = await rest.runMethod(
|
||||
"post",
|
||||
endpoints.GUILD_ROLES(guildId),
|
||||
{
|
||||
...options,
|
||||
permissions: calculateBits(options?.permissions || []),
|
||||
reason,
|
||||
},
|
||||
);
|
||||
|
||||
const roleData = result as RoleData;
|
||||
const role = await structures.createDiscordenoRole({role: roleData, guild_id: guildId});
|
||||
const role = await structures.createDiscordenoRole({
|
||||
role: result,
|
||||
guild_id: guildId,
|
||||
});
|
||||
const guild = await cacheHandlers.get("guilds", guildId);
|
||||
guild?.roles.set(role.id, role);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user