mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
* perf(plugins/helpers,rest,site,template)!: uppercase rest methods There is no need for us to pass the methods in lower case and then use the `toUpperCase()` method everywhere. Therefore this PR changes every lowercase method to be uppercase (eg. `"get"` => `"GET"`). * template is old version
26 lines
918 B
TypeScript
26 lines
918 B
TypeScript
import { Bot } from "../../bot.ts";
|
|
import { DiscordRole } from "../../types/discord.ts";
|
|
import { Collection } from "../../util/collection.ts";
|
|
|
|
/** Modify the positions of a set of role objects for the guild. Requires the MANAGE_ROLES permission. Returns a list of all of the guild's role objects on success. Fires multiple Guild Role Update Gateway events. */
|
|
export async function modifyRolePositions(bot: Bot, guildId: bigint, options: ModifyRolePositions[]) {
|
|
const roles = await bot.rest.runMethod<DiscordRole[]>(
|
|
bot.rest,
|
|
"PATCH",
|
|
bot.constants.routes.GUILD_ROLES(guildId),
|
|
options,
|
|
);
|
|
|
|
return new Collection(roles.map((role) => {
|
|
const result = bot.transformers.role(bot, { role, guildId });
|
|
return [result.id, result];
|
|
}));
|
|
}
|
|
|
|
export interface ModifyRolePositions {
|
|
/** The role id */
|
|
id: bigint;
|
|
/** The sorting position for the role. */
|
|
position?: number | null;
|
|
}
|