This commit is contained in:
Skillz4Killz
2022-03-16 02:00:10 +00:00
committed by GitHub
parent 6fe5e0b8fd
commit 2a84ac982e
10 changed files with 50 additions and 40 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
/** Handler used to determine max number of shards to use based upon the max concurrency. */ /** Handler used to determine max number of shards to use based upon the max concurrency. */
export function calculateMaxShards(maxShards: number, maxConcurrency: number): number { export function calculateMaxShards(maxShards: number, maxConcurrency: number): number {
if (maxShards < 100) return maxShards; if (maxShards < 100) return maxShards;
return Math.ceil( return Math.ceil(
maxShards / maxShards /
(maxConcurrency === 1 ? 16 : maxConcurrency), (maxConcurrency === 1 ? 16 : maxConcurrency),
+1 -1
View File
@@ -27,4 +27,4 @@ export interface ModifyWebhook {
channelId?: bigint; channelId?: bigint;
/** The reason you are modifying this webhook */ /** The reason you are modifying this webhook */
reason?: string; reason?: string;
} }
+1 -1
View File
@@ -1,4 +1,4 @@
import { Bot, Collection, DiscordGuildEmojisUpdate, } from "./deps.ts"; import { Bot, Collection, DiscordGuildEmojisUpdate } from "./deps.ts";
import { setupCacheRemovals } from "./src/setupCacheRemovals.ts"; import { setupCacheRemovals } from "./src/setupCacheRemovals.ts";
import { addCacheCollections, BotWithCache } from "./src/addCacheCollections.ts"; import { addCacheCollections, BotWithCache } from "./src/addCacheCollections.ts";
import { setupCacheEdits } from "./src/setupCacheEdits.ts"; import { setupCacheEdits } from "./src/setupCacheEdits.ts";
+1 -10
View File
@@ -1,13 +1,4 @@
import { import { Bot, Channel, Collection, Guild, Member, Message, PresenceUpdate, User } from "../deps.ts";
Bot,
Collection,
Channel,
Guild,
Member,
Message,
PresenceUpdate,
User,
} from "../deps.ts";
export type BotWithCache<B extends Bot = Bot> = B & CacheProps; export type BotWithCache<B extends Bot = Bot> = B & CacheProps;
+8 -1
View File
@@ -1,4 +1,11 @@
import type { Bot, DiscordGuildMemberAdd, DiscordGuildMemberRemove, DiscordMessageReactionAdd, DiscordMessageReactionRemove, DiscordMessageReactionRemoveAll } from "../deps.ts"; import type {
Bot,
DiscordGuildMemberAdd,
DiscordGuildMemberRemove,
DiscordMessageReactionAdd,
DiscordMessageReactionRemove,
DiscordMessageReactionRemoveAll,
} from "../deps.ts";
import type { BotWithCache } from "./addCacheCollections.ts"; import type { BotWithCache } from "./addCacheCollections.ts";
export function setupCacheEdits<B extends Bot>(bot: BotWithCache<B>) { export function setupCacheEdits<B extends Bot>(bot: BotWithCache<B>) {
+3 -3
View File
@@ -1,13 +1,13 @@
import { import {
ApplicationCommandOptionChoice, ApplicationCommandOptionChoice,
Bot, Bot,
Channel,
Collection, Collection,
CreateMessage, CreateMessage,
Channel,
Member,
Message,
FinalHelpers, FinalHelpers,
ListGuildMembers, ListGuildMembers,
Member,
Message,
} from "./deps.ts"; } from "./deps.ts";
import { cloneChannel } from "./src/channels.ts"; import { cloneChannel } from "./src/channels.ts";
import { sendAutocompleteChoices } from "./src/sendAutoCompleteChoices.ts"; import { sendAutocompleteChoices } from "./src/sendAutoCompleteChoices.ts";
@@ -1,7 +1,12 @@
import type { Bot, DiscordenoInteractionResponse, DiscordenoMessage } from "../deps.ts"; import type { Bot, DiscordenoInteractionResponse, DiscordenoMessage } from "../deps.ts";
/** sendInteractionResponse with ephemeral reply */ /** sendInteractionResponse with ephemeral reply */
export function sendPrivateInteractionResponse(bot: Bot, id: bigint, token: string, options: DiscordenoInteractionResponse): Promise<DiscordenoMessage | undefined> { export function sendPrivateInteractionResponse(
bot: Bot,
id: bigint,
token: string,
options: DiscordenoInteractionResponse,
): Promise<DiscordenoMessage | undefined> {
if (options.data && !options.data?.flags) options.data.flags = 64; // private: true if (options.data && !options.data?.flags) options.data.flags = 64; // private: true
return bot.helpers.sendInteractionResponse(id, token, options); return bot.helpers.sendInteractionResponse(id, token, options);
} }
+13 -8
View File
@@ -22,14 +22,19 @@ export async function unlockThread(bot: Bot, threadId: bigint) {
/** Update a thread's settings. Requires the `MANAGE_CHANNELS` permission for the guild. */ /** Update a thread's settings. Requires the `MANAGE_CHANNELS` permission for the guild. */
export async function editThread(bot: Bot, threadId: bigint, options: ModifyThread, reason?: string) { export async function editThread(bot: Bot, threadId: bigint, options: ModifyThread, reason?: string) {
const result = await bot.rest.runMethod<DiscordChannel>(bot.rest, "patch", bot.constants.endpoints.CHANNEL_BASE(threadId), { const result = await bot.rest.runMethod<DiscordChannel>(
name: options.name, bot.rest,
archived: options.archived, "patch",
auto_archive_duration: options.autoArchiveDuration, bot.constants.endpoints.CHANNEL_BASE(threadId),
locked: options.locked, {
rate_limit_per_user: options.rateLimitPerUser, name: options.name,
reason, archived: options.archived,
}); auto_archive_duration: options.autoArchiveDuration,
locked: options.locked,
rate_limit_per_user: options.rateLimitPerUser,
reason,
},
);
return bot.transformers.channel(bot, { return bot.transformers.channel(bot, {
channel: result, channel: result,
+7 -5
View File
@@ -155,11 +155,13 @@ function makeEmojiFromString(
) { ) {
if (!emoji) return; if (!emoji) return;
if (typeof emoji !== "string") return { if (typeof emoji !== "string") {
id: emoji.id ? BigInt(emoji.id) : undefined, return {
name: emoji.name, id: emoji.id ? BigInt(emoji.id) : undefined,
animated: emoji.animated, name: emoji.name,
}; animated: emoji.animated,
};
}
// A snowflake id was provided // A snowflake id was provided
if (/^[0-9]+$/.test(emoji)) { if (/^[0-9]+$/.test(emoji)) {
@@ -25,15 +25,15 @@ However, you probably want to use something shorter, such as the following:
```js ```js
class Channel { class Channel {
constructor(client, data) { constructor(client, data) {
this.client = client; this.client = client;
this.id = data.id; this.id = data.id;
this.name = data.name; this.name = data.name;
} }
async send(options) { async send(options) {
return await client.helpers.sendMessage(this.id, options); return await client.helpers.sendMessage(this.id, options);
} }
} }
``` ```