Files
discordeno/helpers/guilds/getGuild.ts
ITOH b00504ce07 perf(plugins/helpers,rest,site,template)!: uppercase rest methods (#2252)
* 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
2022-05-25 20:45:51 +02:00

26 lines
651 B
TypeScript

import type { Bot } from "../../bot.ts";
import { DiscordGuild } from "../../types/discord.ts";
/**
* This function fetches a guild's data. This is not the same data as a GUILD_CREATE.
* So it does not cache the guild, you must do it manually.
*/
export async function getGuild(
bot: Bot,
guildId: bigint,
options: { counts?: boolean } = {
counts: true,
},
) {
const result = await bot.rest.runMethod<DiscordGuild>(
bot.rest,
"GET",
bot.constants.routes.GUILD(guildId, options.counts),
);
return bot.transformers.guild(bot, {
guild: result,
shardId: bot.utils.calculateShardId(bot.gateway, guildId),
});
}