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
This commit is contained in:
ITOH
2022-05-25 20:45:51 +02:00
committed by GitHub
parent 1edb3c2110
commit b00504ce07
149 changed files with 157 additions and 157 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ export async function createChannel(bot: Bot, guildId: bigint, options?: CreateG
const result = await bot.rest.runMethod<DiscordChannel>( const result = await bot.rest.runMethod<DiscordChannel>(
bot.rest, bot.rest,
"post", "POST",
bot.constants.routes.GUILD_CHANNELS(guildId), bot.constants.routes.GUILD_CHANNELS(guildId),
options options
? { ? {
+1 -1
View File
@@ -5,7 +5,7 @@ import { DiscordStageInstance } from "../../types/discord.ts";
export async function createStageInstance(bot: Bot, options: CreateStageInstance) { export async function createStageInstance(bot: Bot, options: CreateStageInstance) {
const result = await bot.rest.runMethod<DiscordStageInstance>( const result = await bot.rest.runMethod<DiscordStageInstance>(
bot.rest, bot.rest,
"post", "POST",
bot.constants.routes.STAGE_INSTANCES(), bot.constants.routes.STAGE_INSTANCES(),
{ {
channel_id: options.channelId.toString(), channel_id: options.channelId.toString(),
+1 -1
View File
@@ -5,7 +5,7 @@ import { DiscordChannel } from "../../types/discord.ts";
export async function deleteChannel(bot: Bot, channelId: bigint, reason?: string) { export async function deleteChannel(bot: Bot, channelId: bigint, reason?: string) {
await bot.rest.runMethod<DiscordChannel>( await bot.rest.runMethod<DiscordChannel>(
bot.rest, bot.rest,
"delete", "DELETE",
bot.constants.routes.CHANNEL(channelId), bot.constants.routes.CHANNEL(channelId),
{ {
reason, reason,
+1 -1
View File
@@ -4,7 +4,7 @@ import type { Bot } from "../../bot.ts";
export async function deleteChannelOverwrite(bot: Bot, channelId: bigint, overwriteId: bigint) { export async function deleteChannelOverwrite(bot: Bot, channelId: bigint, overwriteId: bigint) {
await bot.rest.runMethod<undefined>( await bot.rest.runMethod<undefined>(
bot.rest, bot.rest,
"delete", "DELETE",
bot.constants.routes.CHANNEL_OVERWRITE(channelId, overwriteId), bot.constants.routes.CHANNEL_OVERWRITE(channelId, overwriteId),
); );
} }
+1 -1
View File
@@ -2,5 +2,5 @@ import type { Bot } from "../../bot.ts";
/** Deletes the Stage instance. Requires the user to be a moderator of the Stage channel. */ /** Deletes the Stage instance. Requires the user to be a moderator of the Stage channel. */
export async function deleteStageInstance(bot: Bot, channelId: bigint) { export async function deleteStageInstance(bot: Bot, channelId: bigint) {
await bot.rest.runMethod(bot.rest, "delete", bot.constants.routes.STAGE_INSTANCE(channelId)); await bot.rest.runMethod(bot.rest, "DELETE", bot.constants.routes.STAGE_INSTANCE(channelId));
} }
+1 -1
View File
@@ -34,7 +34,7 @@ export async function editChannel(bot: Bot, channelId: bigint, options: ModifyCh
const result = await bot.rest.runMethod<DiscordChannel>( const result = await bot.rest.runMethod<DiscordChannel>(
bot.rest, bot.rest,
"patch", "PATCH",
bot.constants.routes.CHANNEL(channelId), bot.constants.routes.CHANNEL(channelId),
{ {
name: options.name, name: options.name,
+1 -1
View File
@@ -9,7 +9,7 @@ export async function editChannelOverwrite(
) { ) {
await bot.rest.runMethod<undefined>( await bot.rest.runMethod<undefined>(
bot.rest, bot.rest,
"put", "PUT",
bot.constants.routes.CHANNEL_OVERWRITE(channelId, overwrite.id), bot.constants.routes.CHANNEL_OVERWRITE(channelId, overwrite.id),
{ {
allow: overwrite.allow ? bot.utils.calculateBits(overwrite.allow) : "0", allow: overwrite.allow ? bot.utils.calculateBits(overwrite.allow) : "0",
+1 -1
View File
@@ -5,7 +5,7 @@ import { DiscordFollowedChannel } from "../../types/discord.ts";
export async function followChannel(bot: Bot, sourceChannelId: bigint, targetChannelId: bigint) { export async function followChannel(bot: Bot, sourceChannelId: bigint, targetChannelId: bigint) {
const data = await bot.rest.runMethod<DiscordFollowedChannel>( const data = await bot.rest.runMethod<DiscordFollowedChannel>(
bot.rest, bot.rest,
"post", "POST",
bot.constants.routes.CHANNEL_FOLLOW(sourceChannelId), bot.constants.routes.CHANNEL_FOLLOW(sourceChannelId),
{ {
webhook_channel_id: targetChannelId, webhook_channel_id: targetChannelId,
+1 -1
View File
@@ -11,7 +11,7 @@ export async function createForumPost(
) { ) {
const result = await bot.rest.runMethod<DiscordChannel>( const result = await bot.rest.runMethod<DiscordChannel>(
bot.rest, bot.rest,
"post", "POST",
bot.constants.routes.FORUM_START(channelId), bot.constants.routes.FORUM_START(channelId),
{ {
name: options.name, name: options.name,
+1 -1
View File
@@ -5,7 +5,7 @@ import { DiscordChannel } from "../../types/discord.ts";
export async function getChannel(bot: Bot, channelId: bigint) { export async function getChannel(bot: Bot, channelId: bigint) {
const result = await bot.rest.runMethod<DiscordChannel>( const result = await bot.rest.runMethod<DiscordChannel>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.CHANNEL(channelId), bot.constants.routes.CHANNEL(channelId),
); );
+1 -1
View File
@@ -6,7 +6,7 @@ import { DiscordWebhook } from "../../types/discord.ts";
export async function getChannelWebhooks(bot: Bot, channelId: bigint) { export async function getChannelWebhooks(bot: Bot, channelId: bigint) {
const result = await bot.rest.runMethod<DiscordWebhook[]>( const result = await bot.rest.runMethod<DiscordWebhook[]>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.CHANNEL_WEBHOOKS(channelId), bot.constants.routes.CHANNEL_WEBHOOKS(channelId),
); );
+1 -1
View File
@@ -6,7 +6,7 @@ import { DiscordChannel } from "../../types/discord.ts";
export async function getChannels(bot: Bot, guildId: bigint) { export async function getChannels(bot: Bot, guildId: bigint) {
const result = await bot.rest.runMethod<DiscordChannel[]>( const result = await bot.rest.runMethod<DiscordChannel[]>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.GUILD_CHANNELS(guildId), bot.constants.routes.GUILD_CHANNELS(guildId),
); );
+1 -1
View File
@@ -5,7 +5,7 @@ import { DiscordMessage } from "../../types/discord.ts";
export async function getPins(bot: Bot, channelId: bigint) { export async function getPins(bot: Bot, channelId: bigint) {
const result = await bot.rest.runMethod<DiscordMessage[]>( const result = await bot.rest.runMethod<DiscordMessage[]>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.CHANNEL_PINS(channelId), bot.constants.routes.CHANNEL_PINS(channelId),
); );
+1 -1
View File
@@ -5,7 +5,7 @@ import { DiscordStageInstance } from "../../types/discord.ts";
export async function getStageInstance(bot: Bot, channelId: bigint) { export async function getStageInstance(bot: Bot, channelId: bigint) {
const result = await bot.rest.runMethod<DiscordStageInstance>( const result = await bot.rest.runMethod<DiscordStageInstance>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.STAGE_INSTANCE(channelId), bot.constants.routes.STAGE_INSTANCE(channelId),
); );
+1 -1
View File
@@ -6,5 +6,5 @@ import type { Bot } from "../../bot.ts";
* this endpoint may be called to let the user know that the bot is processing their message. * this endpoint may be called to let the user know that the bot is processing their message.
*/ */
export async function startTyping(bot: Bot, channelId: bigint) { export async function startTyping(bot: Bot, channelId: bigint) {
await bot.rest.runMethod<undefined>(bot.rest, "post", bot.constants.routes.CHANNEL_TYPING(channelId)); await bot.rest.runMethod<undefined>(bot.rest, "POST", bot.constants.routes.CHANNEL_TYPING(channelId));
} }
+1 -1
View File
@@ -8,7 +8,7 @@ export async function swapChannels(bot: Bot, guildId: bigint, channelPositions:
await bot.rest.runMethod<undefined>( await bot.rest.runMethod<undefined>(
bot.rest, bot.rest,
"patch", "PATCH",
bot.constants.routes.GUILD_CHANNELS(guildId), bot.constants.routes.GUILD_CHANNELS(guildId),
channelPositions.map((channelPosition) => { channelPositions.map((channelPosition) => {
return { return {
+1 -1
View File
@@ -2,5 +2,5 @@ import type { Bot } from "../../../bot.ts";
/** Adds a user to a thread. Requires the ability to send messages in the thread. Requires the thread is not archived. */ /** Adds a user to a thread. Requires the ability to send messages in the thread. Requires the thread is not archived. */
export async function addToThread(bot: Bot, threadId: bigint, userId: bigint) { export async function addToThread(bot: Bot, threadId: bigint, userId: bigint) {
await bot.rest.runMethod<undefined>(bot.rest, "put", bot.constants.routes.THREAD_USER(threadId, userId)); await bot.rest.runMethod<undefined>(bot.rest, "PUT", bot.constants.routes.THREAD_USER(threadId, userId));
} }
+1 -1
View File
@@ -6,7 +6,7 @@ import { Collection } from "../../../util/collection.ts";
export async function getActiveThreads(bot: Bot, guildId: bigint) { export async function getActiveThreads(bot: Bot, guildId: bigint) {
const result = await bot.rest.runMethod<DiscordListActiveThreads>( const result = await bot.rest.runMethod<DiscordListActiveThreads>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.THREAD_ACTIVE(guildId), bot.constants.routes.THREAD_ACTIVE(guildId),
); );
@@ -18,7 +18,7 @@ export async function getArchivedThreads(
const result = (await bot.rest.runMethod<DiscordListArchivedThreads>( const result = (await bot.rest.runMethod<DiscordListArchivedThreads>(
bot.rest, bot.rest,
"get", "GET",
url, url,
)); ));
+1 -1
View File
@@ -5,7 +5,7 @@ import { DiscordThreadMember } from "../../../types/discord.ts";
export async function getThreadMember(bot: Bot, threadId: bigint, userId: bigint) { export async function getThreadMember(bot: Bot, threadId: bigint, userId: bigint) {
const result = await bot.rest.runMethod<DiscordThreadMember>( const result = await bot.rest.runMethod<DiscordThreadMember>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.THREAD_USER(threadId, userId), bot.constants.routes.THREAD_USER(threadId, userId),
); );
+1 -1
View File
@@ -6,7 +6,7 @@ import { Collection } from "../../../util/collection.ts";
export async function getThreadMembers(bot: Bot, threadId: bigint) { export async function getThreadMembers(bot: Bot, threadId: bigint) {
const result = await bot.rest.runMethod<DiscordThreadMember[]>( const result = await bot.rest.runMethod<DiscordThreadMember[]>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.THREAD_MEMBERS(threadId), bot.constants.routes.THREAD_MEMBERS(threadId),
); );
// return result; // return result;
+1 -1
View File
@@ -2,5 +2,5 @@ import type { Bot } from "../../../bot.ts";
/** Adds the bot to the thread. Cannot join an archived thread. */ /** Adds the bot to the thread. Cannot join an archived thread. */
export async function joinThread(bot: Bot, threadId: bigint) { export async function joinThread(bot: Bot, threadId: bigint) {
await bot.rest.runMethod<undefined>(bot.rest, "put", bot.constants.routes.THREAD_ME(threadId)); await bot.rest.runMethod<undefined>(bot.rest, "PUT", bot.constants.routes.THREAD_ME(threadId));
} }
+1 -1
View File
@@ -2,5 +2,5 @@ import type { Bot } from "../../../bot.ts";
/** Removes the bot from a thread. Requires the thread is not archived. */ /** Removes the bot from a thread. Requires the thread is not archived. */
export async function leaveThread(bot: Bot, threadId: bigint) { export async function leaveThread(bot: Bot, threadId: bigint) {
await bot.rest.runMethod<undefined>(bot.rest, "delete", bot.constants.routes.THREAD_ME(threadId)); await bot.rest.runMethod<undefined>(bot.rest, "DELETE", bot.constants.routes.THREAD_ME(threadId));
} }
@@ -2,5 +2,5 @@ import type { Bot } from "../../../bot.ts";
/** Removes a user from a thread. Requires the MANAGE_THREADS permission or that you are the creator of the thread. Also requires the thread is not archived. */ /** Removes a user from a thread. Requires the MANAGE_THREADS permission or that you are the creator of the thread. Also requires the thread is not archived. */
export async function removeThreadMember(bot: Bot, threadId: bigint, userId: bigint) { export async function removeThreadMember(bot: Bot, threadId: bigint, userId: bigint) {
await bot.rest.runMethod<undefined>(bot.rest, "delete", bot.constants.routes.THREAD_USER(threadId, userId)); await bot.rest.runMethod<undefined>(bot.rest, "DELETE", bot.constants.routes.THREAD_USER(threadId, userId));
} }
@@ -10,7 +10,7 @@ export async function startThreadWithMessage(
) { ) {
const result = await bot.rest.runMethod<DiscordChannel>( const result = await bot.rest.runMethod<DiscordChannel>(
bot.rest, bot.rest,
"post", "POST",
bot.constants.routes.THREAD_START_PUBLIC(channelId, messageId), bot.constants.routes.THREAD_START_PUBLIC(channelId, messageId),
{ {
name: options.name, name: options.name,
@@ -6,7 +6,7 @@ import { ChannelTypes } from "../../../types/shared.ts";
export async function startThreadWithoutMessage(bot: Bot, channelId: bigint, options: StartThreadWithoutMessage) { export async function startThreadWithoutMessage(bot: Bot, channelId: bigint, options: StartThreadWithoutMessage) {
const result = await bot.rest.runMethod<DiscordChannel>( const result = await bot.rest.runMethod<DiscordChannel>(
bot.rest, bot.rest,
"post", "POST",
bot.constants.routes.THREAD_START_PRIVATE(channelId), bot.constants.routes.THREAD_START_PRIVATE(channelId),
{ {
name: options.name, name: options.name,
+1 -1
View File
@@ -10,7 +10,7 @@ export async function updateStageInstance(
) { ) {
const result = await bot.rest.runMethod<DiscordStageInstance>( const result = await bot.rest.runMethod<DiscordStageInstance>(
bot.rest, bot.rest,
"patch", "PATCH",
bot.constants.routes.STAGE_INSTANCE(channelId), bot.constants.routes.STAGE_INSTANCE(channelId),
{ {
topic: data.topic, topic: data.topic,
+2 -2
View File
@@ -11,7 +11,7 @@ import type { Bot } from "../../bot.ts";
* - When suppressed, the user will have their `request_to_speak_timestamp` removed. * - When suppressed, the user will have their `request_to_speak_timestamp` removed.
*/ */
export async function updateBotVoiceState(bot: Bot, guildId: bigint, options: UpdateSelfVoiceState) { export async function updateBotVoiceState(bot: Bot, guildId: bigint, options: UpdateSelfVoiceState) {
await bot.rest.runMethod(bot.rest, "patch", bot.constants.routes.UPDATE_VOICE_STATE(guildId), { await bot.rest.runMethod(bot.rest, "PATCH", bot.constants.routes.UPDATE_VOICE_STATE(guildId), {
channel_id: options.channelId, channel_id: options.channelId,
suppress: options.suppress, suppress: options.suppress,
request_to_speak_timestamp: options.requestToSpeakTimestamp request_to_speak_timestamp: options.requestToSpeakTimestamp
@@ -34,7 +34,7 @@ export async function updateBotVoiceState(bot: Bot, guildId: bigint, options: Up
export async function updateUserVoiceState(bot: Bot, guildId: bigint, options: UpdateOthersVoiceState) { export async function updateUserVoiceState(bot: Bot, guildId: bigint, options: UpdateOthersVoiceState) {
await bot.rest.runMethod( await bot.rest.runMethod(
bot.rest, bot.rest,
"patch", "PATCH",
bot.constants.routes.UPDATE_VOICE_STATE(guildId, options.userId), bot.constants.routes.UPDATE_VOICE_STATE(guildId, options.userId),
{ {
channel_id: options.channelId, channel_id: options.channelId,
+1 -1
View File
@@ -5,7 +5,7 @@ import { DiscordAddGuildDiscoverySubcategory } from "../../types/discord.ts";
export async function addDiscoverySubcategory(bot: Bot, guildId: bigint, categoryId: number) { export async function addDiscoverySubcategory(bot: Bot, guildId: bigint, categoryId: number) {
await bot.rest.runMethod<DiscordAddGuildDiscoverySubcategory>( await bot.rest.runMethod<DiscordAddGuildDiscoverySubcategory>(
bot.rest, bot.rest,
"post", "POST",
bot.constants.routes.DISCOVERY_SUBCATEGORY(guildId, categoryId), bot.constants.routes.DISCOVERY_SUBCATEGORY(guildId, categoryId),
); );
} }
+1 -1
View File
@@ -5,7 +5,7 @@ import { DiscordDiscoveryMetadata } from "../../types/discord.ts";
export async function editDiscovery(bot: Bot, guildId: bigint, data: ModifyGuildDiscoveryMetadata) { export async function editDiscovery(bot: Bot, guildId: bigint, data: ModifyGuildDiscoveryMetadata) {
const result = await bot.rest.runMethod<DiscordDiscoveryMetadata>( const result = await bot.rest.runMethod<DiscordDiscoveryMetadata>(
bot.rest, bot.rest,
"patch", "PATCH",
bot.constants.routes.DISCOVERY_METADATA(guildId), bot.constants.routes.DISCOVERY_METADATA(guildId),
{ {
primary_category_id: data.primaryCategoryId, primary_category_id: data.primaryCategoryId,
+1 -1
View File
@@ -5,7 +5,7 @@ import { DiscordDiscoveryMetadata } from "../../types/discord.ts";
export async function getDiscovery(bot: Bot, guildId: bigint) { export async function getDiscovery(bot: Bot, guildId: bigint) {
const result = await bot.rest.runMethod<DiscordDiscoveryMetadata>( const result = await bot.rest.runMethod<DiscordDiscoveryMetadata>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.DISCOVERY_METADATA(guildId), bot.constants.routes.DISCOVERY_METADATA(guildId),
); );
+1 -1
View File
@@ -6,7 +6,7 @@ import { DiscordDiscoveryCategory } from "../../types/discord.ts";
export async function getDiscoveryCategories(bot: Bot) { export async function getDiscoveryCategories(bot: Bot) {
const result = await bot.rest.runMethod<DiscordDiscoveryCategory[]>( const result = await bot.rest.runMethod<DiscordDiscoveryCategory[]>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.DISCOVERY_CATEGORIES(), bot.constants.routes.DISCOVERY_CATEGORIES(),
); );
@@ -4,7 +4,7 @@ import type { Bot } from "../../bot.ts";
export async function removeDiscoverySubcategory(bot: Bot, guildId: bigint, categoryId: number) { export async function removeDiscoverySubcategory(bot: Bot, guildId: bigint, categoryId: number) {
await bot.rest.runMethod<undefined>( await bot.rest.runMethod<undefined>(
bot.rest, bot.rest,
"delete", "DELETE",
bot.constants.routes.DISCOVERY_SUBCATEGORY(guildId, categoryId), bot.constants.routes.DISCOVERY_SUBCATEGORY(guildId, categoryId),
); );
} }
+1 -1
View File
@@ -4,7 +4,7 @@ import { DiscordValidateDiscoverySearchTerm } from "../../types/discord.ts";
export async function validDiscoveryTerm(bot: Bot, term: string) { export async function validDiscoveryTerm(bot: Bot, term: string) {
const result = await bot.rest.runMethod<DiscordValidateDiscoverySearchTerm>( const result = await bot.rest.runMethod<DiscordValidateDiscoverySearchTerm>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.DISCOVERY_VALID_TERM(term), bot.constants.routes.DISCOVERY_VALID_TERM(term),
); );
+1 -1
View File
@@ -9,7 +9,7 @@ export async function createEmoji(bot: Bot, guildId: bigint, options: CreateGuil
const emoji = await bot.rest.runMethod<DiscordEmoji>( const emoji = await bot.rest.runMethod<DiscordEmoji>(
bot.rest, bot.rest,
"post", "POST",
bot.constants.routes.GUILD_EMOJIS(guildId), bot.constants.routes.GUILD_EMOJIS(guildId),
{ {
name: options.name, name: options.name,
+1 -1
View File
@@ -2,7 +2,7 @@ import type { Bot } from "../../bot.ts";
/** Delete the given emoji. Requires the MANAGE_EMOJIS permission. Returns 204 No Content on success. */ /** Delete the given emoji. Requires the MANAGE_EMOJIS permission. Returns 204 No Content on success. */
export async function deleteEmoji(bot: Bot, guildId: bigint, id: bigint, reason?: string) { export async function deleteEmoji(bot: Bot, guildId: bigint, id: bigint, reason?: string) {
await bot.rest.runMethod<undefined>(bot.rest, "delete", bot.constants.routes.GUILD_EMOJI(guildId, id), { await bot.rest.runMethod<undefined>(bot.rest, "DELETE", bot.constants.routes.GUILD_EMOJI(guildId, id), {
reason, reason,
}); });
} }
+1 -1
View File
@@ -5,7 +5,7 @@ import { DiscordEmoji } from "../../types/discord.ts";
export async function editEmoji(bot: Bot, guildId: bigint, id: bigint, options: ModifyGuildEmoji) { export async function editEmoji(bot: Bot, guildId: bigint, id: bigint, options: ModifyGuildEmoji) {
const result = await bot.rest.runMethod<DiscordEmoji>( const result = await bot.rest.runMethod<DiscordEmoji>(
bot.rest, bot.rest,
"patch", "PATCH",
bot.constants.routes.GUILD_EMOJI(guildId, id), bot.constants.routes.GUILD_EMOJI(guildId, id),
{ {
name: options.name, name: options.name,
+1 -1
View File
@@ -7,7 +7,7 @@ import { DiscordEmoji } from "../../types/discord.ts";
export async function getEmoji(bot: Bot, guildId: bigint, emojiId: bigint) { export async function getEmoji(bot: Bot, guildId: bigint, emojiId: bigint) {
const result = await bot.rest.runMethod<DiscordEmoji>( const result = await bot.rest.runMethod<DiscordEmoji>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.GUILD_EMOJI(guildId, emojiId), bot.constants.routes.GUILD_EMOJI(guildId, emojiId),
); );
+1 -1
View File
@@ -8,7 +8,7 @@ import { Collection } from "../../util/collection.ts";
export async function getEmojis(bot: Bot, guildId: bigint) { export async function getEmojis(bot: Bot, guildId: bigint) {
const result = await bot.rest.runMethod<DiscordEmoji[]>( const result = await bot.rest.runMethod<DiscordEmoji[]>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.GUILD_EMOJIS(guildId), bot.constants.routes.GUILD_EMOJIS(guildId),
); );
+1 -1
View File
@@ -11,7 +11,7 @@ import {
/** Create a new guild. Returns a guild object on success. Fires a Guild Create Gateway event. This endpoint can be used only by bots in less than 10 guilds. */ /** Create a new guild. Returns a guild object on success. Fires a Guild Create Gateway event. This endpoint can be used only by bots in less than 10 guilds. */
export async function createGuild(bot: Bot, options: CreateGuild) { export async function createGuild(bot: Bot, options: CreateGuild) {
const result = await bot.rest.runMethod<DiscordGuild>(bot.rest, "post", bot.constants.routes.GUILDS(), { const result = await bot.rest.runMethod<DiscordGuild>(bot.rest, "POST", bot.constants.routes.GUILDS(), {
name: options.name, name: options.name,
afk_channel_id: options.afkChannelId, afk_channel_id: options.afkChannelId,
afk_timeout: options.afkTimeout, afk_timeout: options.afkTimeout,
+1 -1
View File
@@ -2,5 +2,5 @@ import type { Bot } from "../../bot.ts";
/** Delete a guild permanently. User must be owner. Returns 204 No Content on success. Fires a Guild Delete Gateway event. */ /** Delete a guild permanently. User must be owner. Returns 204 No Content on success. Fires a Guild Delete Gateway event. */
export async function deleteGuild(bot: Bot, guildId: bigint) { export async function deleteGuild(bot: Bot, guildId: bigint) {
await bot.rest.runMethod<undefined>(bot.rest, "delete", bot.constants.routes.GUILD(guildId)); await bot.rest.runMethod<undefined>(bot.rest, "DELETE", bot.constants.routes.GUILD(guildId));
} }
+1 -1
View File
@@ -24,7 +24,7 @@ export async function editGuild(bot: Bot, guildId: bigint, options: ModifyGuild,
const result = await bot.rest.runMethod<DiscordGuild>( const result = await bot.rest.runMethod<DiscordGuild>(
bot.rest, bot.rest,
"patch", "PATCH",
bot.constants.routes.GUILD(guildId), bot.constants.routes.GUILD(guildId),
options, options,
); );
+1 -1
View File
@@ -4,7 +4,7 @@ import { DiscordWelcomeScreen } from "../../types/discord.ts";
export async function editWelcomeScreen(bot: Bot, guildId: bigint, options: ModifyGuildWelcomeScreen) { export async function editWelcomeScreen(bot: Bot, guildId: bigint, options: ModifyGuildWelcomeScreen) {
const result = await bot.rest.runMethod<DiscordWelcomeScreen>( const result = await bot.rest.runMethod<DiscordWelcomeScreen>(
bot.rest, bot.rest,
"patch", "PATCH",
bot.constants.routes.GUILD_WELCOME_SCREEN(guildId), bot.constants.routes.GUILD_WELCOME_SCREEN(guildId),
{ {
enabled: options.enabled, enabled: options.enabled,
+1 -1
View File
@@ -5,7 +5,7 @@ import { DiscordGuildWidgetSettings } from "../../types/discord.ts";
export async function editWidget(bot: Bot, guildId: bigint, enabled: boolean, channelId?: string | null) { export async function editWidget(bot: Bot, guildId: bigint, enabled: boolean, channelId?: string | null) {
const result = await bot.rest.runMethod<DiscordGuildWidgetSettings>( const result = await bot.rest.runMethod<DiscordGuildWidgetSettings>(
bot.rest, bot.rest,
"patch", "PATCH",
bot.constants.routes.GUILD_WIDGET(guildId), bot.constants.routes.GUILD_WIDGET(guildId),
{ {
enabled, enabled,
+1 -1
View File
@@ -8,7 +8,7 @@ export async function getAuditLogs(bot: Bot, guildId: bigint, options?: GetGuild
const auditlog = await bot.rest.runMethod<DiscordAuditLog>( const auditlog = await bot.rest.runMethod<DiscordAuditLog>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.GUILD_AUDIT_LOGS(guildId, options), bot.constants.routes.GUILD_AUDIT_LOGS(guildId, options),
); );
+1 -1
View File
@@ -6,7 +6,7 @@ import { Collection } from "../../util/collection.ts";
export async function getAvailableVoiceRegions(bot: Bot) { export async function getAvailableVoiceRegions(bot: Bot) {
const result = await bot.rest.runMethod<DiscordVoiceRegion[]>( const result = await bot.rest.runMethod<DiscordVoiceRegion[]>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.VOICE_REGIONS(), bot.constants.routes.VOICE_REGIONS(),
); );
+1 -1
View File
@@ -5,7 +5,7 @@ import { DiscordBan } from "../../types/discord.ts";
export async function getBan(bot: Bot, guildId: bigint, memberId: bigint) { export async function getBan(bot: Bot, guildId: bigint, memberId: bigint) {
const result = await bot.rest.runMethod<DiscordBan>( const result = await bot.rest.runMethod<DiscordBan>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.GUILD_BAN(guildId, memberId), bot.constants.routes.GUILD_BAN(guildId, memberId),
); );
+1 -1
View File
@@ -7,7 +7,7 @@ import { User } from "../../transformers/member.ts";
export async function getBans(bot: Bot, guildId: bigint, options?: GetBans) { export async function getBans(bot: Bot, guildId: bigint, options?: GetBans) {
const results = await bot.rest.runMethod<DiscordBan[]>( const results = await bot.rest.runMethod<DiscordBan[]>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.GUILD_BANS(guildId, options), bot.constants.routes.GUILD_BANS(guildId, options),
); );
+1 -1
View File
@@ -14,7 +14,7 @@ export async function getGuild(
) { ) {
const result = await bot.rest.runMethod<DiscordGuild>( const result = await bot.rest.runMethod<DiscordGuild>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.GUILD(guildId, options.counts), bot.constants.routes.GUILD(guildId, options.counts),
); );
+1 -1
View File
@@ -5,7 +5,7 @@ import { DiscordGuildPreview } from "../../types/discord.ts";
export async function getGuildPreview(bot: Bot, guildId: bigint) { export async function getGuildPreview(bot: Bot, guildId: bigint) {
const result = await bot.rest.runMethod<DiscordGuildPreview>( const result = await bot.rest.runMethod<DiscordGuildPreview>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.GUILD_PREVIEW(guildId), bot.constants.routes.GUILD_PREVIEW(guildId),
); );
+1 -1
View File
@@ -7,7 +7,7 @@ export async function getPruneCount(bot: Bot, guildId: bigint, options?: GetGuil
const result = await bot.rest.runMethod( const result = await bot.rest.runMethod(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.GUILD_PRUNE(guildId), bot.constants.routes.GUILD_PRUNE(guildId),
); );
+1 -1
View File
@@ -5,7 +5,7 @@ import { DiscordInviteMetadata } from "../../types/discord.ts";
export async function getVanityUrl(bot: Bot, guildId: bigint) { export async function getVanityUrl(bot: Bot, guildId: bigint) {
const result = await bot.rest.runMethod<Partial<DiscordInviteMetadata>>( const result = await bot.rest.runMethod<Partial<DiscordInviteMetadata>>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.GUILD_VANITY_URL(guildId), bot.constants.routes.GUILD_VANITY_URL(guildId),
); );
+1 -1
View File
@@ -6,7 +6,7 @@ import { DiscordVoiceRegion } from "../../types/discord.ts";
export async function getVoiceRegions(bot: Bot, guildId: bigint) { export async function getVoiceRegions(bot: Bot, guildId: bigint) {
const result = await bot.rest.runMethod<DiscordVoiceRegion[]>( const result = await bot.rest.runMethod<DiscordVoiceRegion[]>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.GUILD_REGIONS(guildId), bot.constants.routes.GUILD_REGIONS(guildId),
); );
+1 -1
View File
@@ -5,7 +5,7 @@ import { DiscordWelcomeScreen } from "../../types/discord.ts";
export async function getWelcomeScreen(bot: Bot, guildId: bigint) { export async function getWelcomeScreen(bot: Bot, guildId: bigint) {
const result = await bot.rest.runMethod<DiscordWelcomeScreen>( const result = await bot.rest.runMethod<DiscordWelcomeScreen>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.GUILD_WELCOME_SCREEN(guildId), bot.constants.routes.GUILD_WELCOME_SCREEN(guildId),
); );
+1 -1
View File
@@ -5,7 +5,7 @@ import { DiscordGuildWidget } from "../../types/discord.ts";
export async function getWidget(bot: Bot, guildId: bigint) { export async function getWidget(bot: Bot, guildId: bigint) {
const result = await bot.rest.runMethod<DiscordGuildWidget>( const result = await bot.rest.runMethod<DiscordGuildWidget>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.GUILD_WIDGET_JSON(guildId), bot.constants.routes.GUILD_WIDGET_JSON(guildId),
); );
+1 -1
View File
@@ -5,7 +5,7 @@ import { DiscordGuildWidgetSettings } from "../../types/discord.ts";
export async function getWidgetSettings(bot: Bot, guildId: bigint) { export async function getWidgetSettings(bot: Bot, guildId: bigint) {
const result = await bot.rest.runMethod<DiscordGuildWidgetSettings>( const result = await bot.rest.runMethod<DiscordGuildWidgetSettings>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.GUILD_WIDGET(guildId), bot.constants.routes.GUILD_WIDGET(guildId),
); );
+1 -1
View File
@@ -2,5 +2,5 @@ import type { Bot } from "../../bot.ts";
/** Leave a guild */ /** Leave a guild */
export async function leaveGuild(bot: Bot, guildId: bigint) { export async function leaveGuild(bot: Bot, guildId: bigint) {
await bot.rest.runMethod<undefined>(bot.rest, "delete", bot.constants.routes.GUILD_LEAVE(guildId)); await bot.rest.runMethod<undefined>(bot.rest, "DELETE", bot.constants.routes.GUILD_LEAVE(guildId));
} }
@@ -28,7 +28,7 @@ export async function createScheduledEvent(bot: Bot, guildId: bigint, options: C
const event = await bot.rest.runMethod<DiscordScheduledEvent>( const event = await bot.rest.runMethod<DiscordScheduledEvent>(
bot.rest, bot.rest,
"post", "POST",
bot.constants.routes.GUILD_SCHEDULED_EVENTS(guildId), bot.constants.routes.GUILD_SCHEDULED_EVENTS(guildId),
{ {
channel_id: options.channelId?.toString(), channel_id: options.channelId?.toString(),
@@ -4,7 +4,7 @@ import { Bot } from "../../../bot.ts";
export async function deleteScheduledEvent(bot: Bot, guildId: bigint, eventId: bigint) { export async function deleteScheduledEvent(bot: Bot, guildId: bigint, eventId: bigint) {
await bot.rest.runMethod<undefined>( await bot.rest.runMethod<undefined>(
bot.rest, bot.rest,
"delete", "DELETE",
bot.constants.routes.GUILD_SCHEDULED_EVENT(guildId, eventId), bot.constants.routes.GUILD_SCHEDULED_EVENT(guildId, eventId),
); );
} }
@@ -24,7 +24,7 @@ export async function editScheduledEvent(
const event = await bot.rest.runMethod<DiscordScheduledEvent>( const event = await bot.rest.runMethod<DiscordScheduledEvent>(
bot.rest, bot.rest,
"patch", "PATCH",
bot.constants.routes.GUILD_SCHEDULED_EVENT(guildId, eventId), bot.constants.routes.GUILD_SCHEDULED_EVENT(guildId, eventId),
{ {
channel_id: options.channelId === null ? null : options.channelId?.toString(), channel_id: options.channelId === null ? null : options.channelId?.toString(),
@@ -10,7 +10,7 @@ export async function getScheduledEvent(
) { ) {
const event = await bot.rest.runMethod<DiscordScheduledEvent>( const event = await bot.rest.runMethod<DiscordScheduledEvent>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.GUILD_SCHEDULED_EVENT(guildId, eventId, options?.withUserCount), bot.constants.routes.GUILD_SCHEDULED_EVENT(guildId, eventId, options?.withUserCount),
); );
@@ -36,7 +36,7 @@ export async function getScheduledEventUsers(
const result = await bot.rest.runMethod<{ user: DiscordUser; member?: DiscordMember }[]>( const result = await bot.rest.runMethod<{ user: DiscordUser; member?: DiscordMember }[]>(
bot.rest, bot.rest,
"get", "GET",
url, url,
); );
@@ -7,7 +7,7 @@ import { Collection } from "../../../util/collection.ts";
export async function getScheduledEvents(bot: Bot, guildId: bigint, options?: GetScheduledEvents) { export async function getScheduledEvents(bot: Bot, guildId: bigint, options?: GetScheduledEvents) {
const events = await bot.rest.runMethod<DiscordScheduledEvent[]>( const events = await bot.rest.runMethod<DiscordScheduledEvent[]>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.GUILD_SCHEDULED_EVENTS(guildId, options?.withUserCount), bot.constants.routes.GUILD_SCHEDULED_EVENTS(guildId, options?.withUserCount),
); );
+1 -1
View File
@@ -2,5 +2,5 @@ import type { Bot } from "../../bot.ts";
/** Delete the attached integration object for the guild with this id. Requires MANAGE_GUILD permission. */ /** Delete the attached integration object for the guild with this id. Requires MANAGE_GUILD permission. */
export async function deleteIntegration(bot: Bot, guildId: bigint, id: bigint) { export async function deleteIntegration(bot: Bot, guildId: bigint, id: bigint) {
await bot.rest.runMethod<undefined>(bot.rest, "delete", bot.constants.routes.GUILD_INTEGRATION(guildId, id)); await bot.rest.runMethod<undefined>(bot.rest, "DELETE", bot.constants.routes.GUILD_INTEGRATION(guildId, id));
} }
+1 -1
View File
@@ -6,7 +6,7 @@ import { DiscordIntegration } from "../../types/discord.ts";
export async function getIntegrations(bot: Bot, guildId: bigint) { export async function getIntegrations(bot: Bot, guildId: bigint) {
const result = await bot.rest.runMethod<DiscordIntegration[]>( const result = await bot.rest.runMethod<DiscordIntegration[]>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.GUILD_INTEGRATIONS(guildId), bot.constants.routes.GUILD_INTEGRATIONS(guildId),
); );
@@ -21,7 +21,7 @@ export async function createApplicationCommand(
) { ) {
const result = await bot.rest.runMethod<DiscordApplicationCommand>( const result = await bot.rest.runMethod<DiscordApplicationCommand>(
bot.rest, bot.rest,
"post", "POST",
guildId guildId
? bot.constants.routes.COMMANDS_GUILD(bot.applicationId, guildId) ? bot.constants.routes.COMMANDS_GUILD(bot.applicationId, guildId)
: bot.constants.routes.COMMANDS(bot.applicationId), : bot.constants.routes.COMMANDS(bot.applicationId),
@@ -4,7 +4,7 @@ import type { Bot } from "../../../bot.ts";
export async function deleteApplicationCommand(bot: Bot, id: bigint, guildId?: bigint) { export async function deleteApplicationCommand(bot: Bot, id: bigint, guildId?: bigint) {
await bot.rest.runMethod<undefined>( await bot.rest.runMethod<undefined>(
bot.rest, bot.rest,
"delete", "DELETE",
guildId guildId
? bot.constants.routes.COMMANDS_GUILD_ID(bot.applicationId, guildId, id) ? bot.constants.routes.COMMANDS_GUILD_ID(bot.applicationId, guildId, id)
: bot.constants.routes.COMMANDS_ID(bot.applicationId, id), : bot.constants.routes.COMMANDS_ID(bot.applicationId, id),
@@ -4,7 +4,7 @@ import type { Bot } from "../../../bot.ts";
export async function deleteInteractionResponse(bot: Bot, token: string, messageId?: bigint) { export async function deleteInteractionResponse(bot: Bot, token: string, messageId?: bigint) {
await bot.rest.runMethod<undefined>( await bot.rest.runMethod<undefined>(
bot.rest, bot.rest,
"delete", "DELETE",
messageId messageId
? bot.constants.routes.INTERACTION_ID_TOKEN_MESSAGE_ID(bot.applicationId, token, messageId) ? bot.constants.routes.INTERACTION_ID_TOKEN_MESSAGE_ID(bot.applicationId, token, messageId)
: bot.constants.routes.INTERACTION_ORIGINAL_ID_TOKEN(bot.applicationId, token), : bot.constants.routes.INTERACTION_ORIGINAL_ID_TOKEN(bot.applicationId, token),
@@ -13,7 +13,7 @@ export async function editApplicationCommandPermissions(
) { ) {
const result = await bot.rest.runMethod<DiscordGuildApplicationCommandPermissions>( const result = await bot.rest.runMethod<DiscordGuildApplicationCommandPermissions>(
bot.rest, bot.rest,
"put", "PUT",
bot.constants.routes.COMMANDS_PERMISSION(bot.applicationId, guildId, commandId), bot.constants.routes.COMMANDS_PERMISSION(bot.applicationId, guildId, commandId),
{ {
permissions: options, permissions: options,
@@ -13,7 +13,7 @@ export async function editInteractionResponse(
) { ) {
const result = await bot.rest.runMethod( const result = await bot.rest.runMethod(
bot.rest, bot.rest,
"patch", "PATCH",
options.messageId options.messageId
? bot.constants.routes.WEBHOOK_MESSAGE(bot.applicationId, token, options.messageId) ? bot.constants.routes.WEBHOOK_MESSAGE(bot.applicationId, token, options.messageId)
: bot.constants.routes.INTERACTION_ORIGINAL_ID_TOKEN(bot.applicationId, token), : bot.constants.routes.INTERACTION_ORIGINAL_ID_TOKEN(bot.applicationId, token),
@@ -5,7 +5,7 @@ import { DiscordApplicationCommand } from "../../../types/discord.ts";
export async function getApplicationCommand(bot: Bot, commandId: bigint, options?: GetApplicationCommand) { export async function getApplicationCommand(bot: Bot, commandId: bigint, options?: GetApplicationCommand) {
const result = await bot.rest.runMethod<DiscordApplicationCommand>( const result = await bot.rest.runMethod<DiscordApplicationCommand>(
bot.rest, bot.rest,
"get", "GET",
options?.guildId options?.guildId
? bot.constants.routes.COMMANDS_GUILD_ID( ? bot.constants.routes.COMMANDS_GUILD_ID(
bot.applicationId, bot.applicationId,
@@ -5,7 +5,7 @@ import { DiscordGuildApplicationCommandPermissions } from "../../../types/discor
export async function getApplicationCommandPermission(bot: Bot, guildId: bigint, commandId: bigint) { export async function getApplicationCommandPermission(bot: Bot, guildId: bigint, commandId: bigint) {
const result = await bot.rest.runMethod<DiscordGuildApplicationCommandPermissions>( const result = await bot.rest.runMethod<DiscordGuildApplicationCommandPermissions>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.COMMANDS_PERMISSION(bot.applicationId, guildId, commandId), bot.constants.routes.COMMANDS_PERMISSION(bot.applicationId, guildId, commandId),
); );
@@ -6,7 +6,7 @@ import { Collection } from "../../../util/collection.ts";
export async function getApplicationCommandPermissions(bot: Bot, guildId: bigint) { export async function getApplicationCommandPermissions(bot: Bot, guildId: bigint) {
const result = await bot.rest.runMethod<DiscordGuildApplicationCommandPermissions[]>( const result = await bot.rest.runMethod<DiscordGuildApplicationCommandPermissions[]>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.COMMANDS_PERMISSIONS(bot.applicationId, guildId), bot.constants.routes.COMMANDS_PERMISSIONS(bot.applicationId, guildId),
); );
@@ -6,7 +6,7 @@ import { DiscordApplicationCommand } from "../../../types/discord.ts";
export async function getApplicationCommands(bot: Bot, guildId?: bigint) { export async function getApplicationCommands(bot: Bot, guildId?: bigint) {
const result = await bot.rest.runMethod<DiscordApplicationCommand[]>( const result = await bot.rest.runMethod<DiscordApplicationCommand[]>(
bot.rest, bot.rest,
"get", "GET",
guildId guildId
? bot.constants.routes.COMMANDS_GUILD(bot.applicationId, guildId) ? bot.constants.routes.COMMANDS_GUILD(bot.applicationId, guildId)
: bot.constants.routes.COMMANDS(bot.applicationId), : bot.constants.routes.COMMANDS(bot.applicationId),
@@ -19,7 +19,7 @@ export async function upsertApplicationCommand(
) { ) {
const result = await bot.rest.runMethod<DiscordApplicationCommand>( const result = await bot.rest.runMethod<DiscordApplicationCommand>(
bot.rest, bot.rest,
"patch", "PATCH",
guildId guildId
? bot.constants.routes.COMMANDS_GUILD_ID(bot.applicationId, guildId, commandId) ? bot.constants.routes.COMMANDS_GUILD_ID(bot.applicationId, guildId, commandId)
: bot.constants.routes.COMMANDS_ID(bot.applicationId, commandId), : bot.constants.routes.COMMANDS_ID(bot.applicationId, commandId),
@@ -21,7 +21,7 @@ export async function upsertApplicationCommands(
) { ) {
const result = await bot.rest.runMethod<DiscordApplicationCommand[]>( const result = await bot.rest.runMethod<DiscordApplicationCommand[]>(
bot.rest, bot.rest,
"put", "PUT",
guildId guildId
? bot.constants.routes.COMMANDS_GUILD(bot.applicationId, guildId) ? bot.constants.routes.COMMANDS_GUILD(bot.applicationId, guildId)
: bot.constants.routes.COMMANDS(bot.applicationId), : bot.constants.routes.COMMANDS(bot.applicationId),
@@ -4,7 +4,7 @@ import { Bot } from "../../../bot.ts";
export async function deleteFollowupMessage(bot: Bot, interactionToken: string, messageId: bigint) { export async function deleteFollowupMessage(bot: Bot, interactionToken: string, messageId: bigint) {
await bot.rest.runMethod<undefined>( await bot.rest.runMethod<undefined>(
bot.rest, bot.rest,
"delete", "DELETE",
bot.constants.routes.WEBHOOK_MESSAGE(bot.applicationId, interactionToken, messageId), bot.constants.routes.WEBHOOK_MESSAGE(bot.applicationId, interactionToken, messageId),
); );
} }
@@ -12,7 +12,7 @@ export async function editFollowupMessage(
) { ) {
const result = await bot.rest.runMethod<DiscordMessage>( const result = await bot.rest.runMethod<DiscordMessage>(
bot.rest, bot.rest,
"patch", "PATCH",
bot.constants.routes.WEBHOOK_MESSAGE(bot.applicationId, interactionToken, messageId), bot.constants.routes.WEBHOOK_MESSAGE(bot.applicationId, interactionToken, messageId),
{ {
content: options.content, content: options.content,
@@ -5,7 +5,7 @@ import { DiscordMessage } from "../../../types/discord.ts";
export async function getFollowupMessage(bot: Bot, interactionToken: string, messageId: bigint) { export async function getFollowupMessage(bot: Bot, interactionToken: string, messageId: bigint) {
const result = await bot.rest.runMethod<DiscordMessage>( const result = await bot.rest.runMethod<DiscordMessage>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.WEBHOOK_MESSAGE(bot.applicationId, interactionToken, messageId), bot.constants.routes.WEBHOOK_MESSAGE(bot.applicationId, interactionToken, messageId),
); );
@@ -5,7 +5,7 @@ import { DiscordMessage } from "../../types/discord.ts";
export async function getOriginalInteractionResponse(bot: Bot, token: string) { export async function getOriginalInteractionResponse(bot: Bot, token: string) {
const result = await bot.rest.runMethod<DiscordMessage>( const result = await bot.rest.runMethod<DiscordMessage>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.INTERACTION_ORIGINAL_ID_TOKEN(bot.applicationId, token), bot.constants.routes.INTERACTION_ORIGINAL_ID_TOKEN(bot.applicationId, token),
); );
@@ -99,7 +99,7 @@ export async function sendInteractionResponse(
if (bot.cache.unrepliedInteractions.delete(id)) { if (bot.cache.unrepliedInteractions.delete(id)) {
return await bot.rest.runMethod<undefined>( return await bot.rest.runMethod<undefined>(
bot.rest, bot.rest,
"post", "POST",
bot.constants.routes.INTERACTION_ID_TOKEN(id, token), bot.constants.routes.INTERACTION_ID_TOKEN(id, token),
{ {
type: options.type, type: options.type,
@@ -112,7 +112,7 @@ export async function sendInteractionResponse(
// If its already been executed, we need to send a followup response // If its already been executed, we need to send a followup response
const result = await bot.rest.runMethod<DiscordMessage>( const result = await bot.rest.runMethod<DiscordMessage>(
bot.rest, bot.rest,
"post", "POST",
bot.constants.routes.WEBHOOK(bot.applicationId, token), bot.constants.routes.WEBHOOK(bot.applicationId, token),
{ ...data, file: options.data.file }, { ...data, file: options.data.file },
); );
+1 -1
View File
@@ -6,7 +6,7 @@ import { InviteTargetTypes } from "../../types/shared.ts";
export async function createInvite(bot: Bot, channelId: bigint, options: CreateChannelInvite = {}) { export async function createInvite(bot: Bot, channelId: bigint, options: CreateChannelInvite = {}) {
const result = await bot.rest.runMethod<DiscordInvite>( const result = await bot.rest.runMethod<DiscordInvite>(
bot.rest, bot.rest,
"post", "POST",
bot.constants.routes.CHANNEL_INVITES(channelId), bot.constants.routes.CHANNEL_INVITES(channelId),
{ {
max_age: options.maxAge, max_age: options.maxAge,
+1 -1
View File
@@ -3,5 +3,5 @@ import { DiscordInviteMetadata } from "../../types/discord.ts";
/** Deletes an invite for the given code. Requires `MANAGE_CHANNELS` or `MANAGE_GUILD` permission */ /** Deletes an invite for the given code. Requires `MANAGE_CHANNELS` or `MANAGE_GUILD` permission */
export async function deleteInvite(bot: Bot, inviteCode: string) { export async function deleteInvite(bot: Bot, inviteCode: string) {
await bot.rest.runMethod<DiscordInviteMetadata>(bot.rest, "delete", bot.constants.routes.INVITE(inviteCode)); await bot.rest.runMethod<DiscordInviteMetadata>(bot.rest, "DELETE", bot.constants.routes.INVITE(inviteCode));
} }
+1 -1
View File
@@ -6,7 +6,7 @@ import { DiscordInviteMetadata } from "../../types/discord.ts";
export async function getChannelInvites(bot: Bot, channelId: bigint) { export async function getChannelInvites(bot: Bot, channelId: bigint) {
const result = await bot.rest.runMethod<DiscordInviteMetadata[]>( const result = await bot.rest.runMethod<DiscordInviteMetadata[]>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.CHANNEL_INVITES(channelId), bot.constants.routes.CHANNEL_INVITES(channelId),
); );
+1 -1
View File
@@ -5,7 +5,7 @@ import { DiscordInviteMetadata } from "../../types/discord.ts";
export async function getInvite(bot: Bot, inviteCode: string, options?: GetInvite) { export async function getInvite(bot: Bot, inviteCode: string, options?: GetInvite) {
const result = await bot.rest.runMethod<DiscordInviteMetadata>( const result = await bot.rest.runMethod<DiscordInviteMetadata>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.INVITE(inviteCode, options), bot.constants.routes.INVITE(inviteCode, options),
); );
+1 -1
View File
@@ -6,7 +6,7 @@ import { DiscordInviteMetadata } from "../../types/discord.ts";
export async function getInvites(bot: Bot, guildId: bigint) { export async function getInvites(bot: Bot, guildId: bigint) {
const result = await bot.rest.runMethod<DiscordInviteMetadata[]>( const result = await bot.rest.runMethod<DiscordInviteMetadata[]>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.GUILD_INVITES(guildId), bot.constants.routes.GUILD_INVITES(guildId),
); );
+1 -1
View File
@@ -4,7 +4,7 @@ import type { Bot } from "../../bot.ts";
export async function banMember(bot: Bot, guildId: bigint, id: bigint, options?: CreateGuildBan) { export async function banMember(bot: Bot, guildId: bigint, id: bigint, options?: CreateGuildBan) {
await bot.rest.runMethod<undefined>( await bot.rest.runMethod<undefined>(
bot.rest, bot.rest,
"put", "PUT",
bot.constants.routes.GUILD_BAN(guildId, id), bot.constants.routes.GUILD_BAN(guildId, id),
options options
? { ? {
+1 -1
View File
@@ -4,7 +4,7 @@ import type { Bot } from "../../bot.ts";
export async function editBotNickname(bot: Bot, guildId: bigint, options: { nick: string | null; reason?: string }) { export async function editBotNickname(bot: Bot, guildId: bigint, options: { nick: string | null; reason?: string }) {
const response = await bot.rest.runMethod<{ nick: string }>( const response = await bot.rest.runMethod<{ nick: string }>(
bot.rest, bot.rest,
"patch", "PATCH",
bot.constants.routes.USER_NICK(guildId), bot.constants.routes.USER_NICK(guildId),
options, options,
); );
+1 -1
View File
@@ -5,7 +5,7 @@ import { DiscordMemberWithUser } from "../../types/discord.ts";
export async function editMember(bot: Bot, guildId: bigint, memberId: bigint, options: ModifyGuildMember) { export async function editMember(bot: Bot, guildId: bigint, memberId: bigint, options: ModifyGuildMember) {
const result = await bot.rest.runMethod<DiscordMemberWithUser>( const result = await bot.rest.runMethod<DiscordMemberWithUser>(
bot.rest, bot.rest,
"patch", "PATCH",
bot.constants.routes.GUILD_MEMBER(guildId, memberId), bot.constants.routes.GUILD_MEMBER(guildId, memberId),
{ {
nick: options.nick, nick: options.nick,
+1 -1
View File
@@ -5,7 +5,7 @@ import { DiscordChannel } from "../../types/discord.ts";
export async function getDmChannel(bot: Bot, userId: bigint) { export async function getDmChannel(bot: Bot, userId: bigint) {
if (userId === bot.id) throw new Error(bot.constants.Errors.YOU_CAN_NOT_DM_THE_BOT_ITSELF); if (userId === bot.id) throw new Error(bot.constants.Errors.YOU_CAN_NOT_DM_THE_BOT_ITSELF);
const dmChannelData = await bot.rest.runMethod<DiscordChannel>(bot.rest, "post", bot.constants.routes.USER_DM(), { const dmChannelData = await bot.rest.runMethod<DiscordChannel>(bot.rest, "POST", bot.constants.routes.USER_DM(), {
recipient_id: userId.toString(), recipient_id: userId.toString(),
}); });
+1 -1
View File
@@ -5,7 +5,7 @@ import { DiscordMemberWithUser } from "../../types/discord.ts";
export async function getMember(bot: Bot, guildId: bigint, id: bigint) { export async function getMember(bot: Bot, guildId: bigint, id: bigint) {
const data = await bot.rest.runMethod<DiscordMemberWithUser>( const data = await bot.rest.runMethod<DiscordMemberWithUser>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.GUILD_MEMBER(guildId, id), bot.constants.routes.GUILD_MEMBER(guildId, id),
); );
+1 -1
View File
@@ -11,7 +11,7 @@ import { Collection } from "../../util/collection.ts";
export async function getMembers(bot: Bot, guildId: bigint, options: ListGuildMembers) { export async function getMembers(bot: Bot, guildId: bigint, options: ListGuildMembers) {
const result = await bot.rest.runMethod<DiscordMemberWithUser[]>( const result = await bot.rest.runMethod<DiscordMemberWithUser[]>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.GUILD_MEMBERS(guildId, options), bot.constants.routes.GUILD_MEMBERS(guildId, options),
); );
+1 -1
View File
@@ -2,7 +2,7 @@ import { Bot } from "../../bot.ts";
/** Kick a member from the server */ /** Kick a member from the server */
export async function kickMember(bot: Bot, guildId: bigint, memberId: bigint, reason?: string) { export async function kickMember(bot: Bot, guildId: bigint, memberId: bigint, reason?: string) {
await bot.rest.runMethod<undefined>(bot.rest, "delete", bot.constants.routes.GUILD_MEMBER(guildId, memberId), { await bot.rest.runMethod<undefined>(bot.rest, "DELETE", bot.constants.routes.GUILD_MEMBER(guildId, memberId), {
reason, reason,
}); });
} }
+1 -1
View File
@@ -11,7 +11,7 @@ export async function pruneMembers(bot: Bot, guildId: bigint, options: BeginGuil
const result = await bot.rest.runMethod<{ pruned: number }>( const result = await bot.rest.runMethod<{ pruned: number }>(
bot.rest, bot.rest,
"post", "POST",
bot.constants.routes.GUILD_PRUNE(guildId), bot.constants.routes.GUILD_PRUNE(guildId),
{ {
days: options.days, days: options.days,
+1 -1
View File
@@ -22,7 +22,7 @@ export async function searchMembers(
const result = await bot.rest.runMethod<DiscordMemberWithUser[]>( const result = await bot.rest.runMethod<DiscordMemberWithUser[]>(
bot.rest, bot.rest,
"get", "GET",
bot.constants.routes.GUILD_MEMBERS_SEARCH(guildId, query, options), bot.constants.routes.GUILD_MEMBERS_SEARCH(guildId, query, options),
); );
+1 -1
View File
@@ -2,5 +2,5 @@ import type { Bot } from "../../bot.ts";
/** Remove the ban for a user. Requires BAN_MEMBERS permission */ /** Remove the ban for a user. Requires BAN_MEMBERS permission */
export async function unbanMember(bot: Bot, guildId: bigint, id: bigint) { export async function unbanMember(bot: Bot, guildId: bigint, id: bigint) {
await bot.rest.runMethod<undefined>(bot.rest, "delete", bot.constants.routes.GUILD_BAN(guildId, id)); await bot.rest.runMethod<undefined>(bot.rest, "DELETE", bot.constants.routes.GUILD_BAN(guildId, id));
} }
+1 -1
View File
@@ -10,7 +10,7 @@ export async function addReaction(bot: Bot, channelId: bigint, messageId: bigint
await bot.rest.runMethod<undefined>( await bot.rest.runMethod<undefined>(
bot.rest, bot.rest,
"put", "PUT",
bot.constants.routes.CHANNEL_MESSAGE_REACTION_ME(channelId, messageId, reaction), bot.constants.routes.CHANNEL_MESSAGE_REACTION_ME(channelId, messageId, reaction),
{}, {},
); );
+1 -1
View File
@@ -12,7 +12,7 @@ export async function deleteMessage(
await bot.rest.runMethod<undefined>( await bot.rest.runMethod<undefined>(
bot.rest, bot.rest,
"delete", "DELETE",
bot.constants.routes.CHANNEL_MESSAGE(channelId, messageId), bot.constants.routes.CHANNEL_MESSAGE(channelId, messageId),
{ reason }, { reason },
); );
+1 -1
View File
@@ -10,7 +10,7 @@ export async function deleteMessages(bot: Bot, channelId: bigint, ids: bigint[],
console.warn(`This endpoint only accepts a maximum of 100 messages. Deleting the first 100 message ids provided.`); console.warn(`This endpoint only accepts a maximum of 100 messages. Deleting the first 100 message ids provided.`);
} }
await bot.rest.runMethod<undefined>(bot.rest, "post", bot.constants.routes.CHANNEL_BULK_DELETE(channelId), { await bot.rest.runMethod<undefined>(bot.rest, "POST", bot.constants.routes.CHANNEL_BULK_DELETE(channelId), {
messages: ids.splice(0, 100).map((id) => id.toString()), messages: ids.splice(0, 100).map((id) => id.toString()),
reason, reason,
}); });
+1 -1
View File
@@ -9,7 +9,7 @@ import { MessageComponentTypes } from "../../types/shared.ts";
export async function editMessage(bot: Bot, channelId: bigint, messageId: bigint, content: EditMessage) { export async function editMessage(bot: Bot, channelId: bigint, messageId: bigint, content: EditMessage) {
const result = await bot.rest.runMethod<DiscordMessage>( const result = await bot.rest.runMethod<DiscordMessage>(
bot.rest, bot.rest,
"patch", "PATCH",
bot.constants.routes.CHANNEL_MESSAGE(channelId, messageId), bot.constants.routes.CHANNEL_MESSAGE(channelId, messageId),
{ {
content: content.content, content: content.content,

Some files were not shown because too many files have changed in this diff Show More