This commit is contained in:
ayntee
2021-04-13 10:19:45 +04:00
9 changed files with 24 additions and 19 deletions
+2 -2
View File
@@ -8,14 +8,14 @@ import { camelKeysToSnakeCase } from "../../util/utils.ts";
export async function ban( export async function ban(
guildId: string, guildId: string,
id: string, id: string,
options: CreateGuildBan options: CreateGuildBan,
) { ) {
await requireBotGuildPermissions(guildId, ["BAN_MEMBERS"]); await requireBotGuildPermissions(guildId, ["BAN_MEMBERS"]);
const result = await rest.runMethod( const result = await rest.runMethod(
"put", "put",
endpoints.GUILD_BAN(guildId, id), endpoints.GUILD_BAN(guildId, id),
camelKeysToSnakeCase(options) camelKeysToSnakeCase(options),
); );
return result; return result;
+4 -1
View File
@@ -10,7 +10,10 @@ import {
requireBotChannelPermissions, requireBotChannelPermissions,
requireBotGuildPermissions, requireBotGuildPermissions,
} from "../../util/permissions.ts"; } from "../../util/permissions.ts";
import { camelKeysToSnakeCase, snakeKeysToCamelCase } from "../../util/utils.ts"; import {
camelKeysToSnakeCase,
snakeKeysToCamelCase,
} from "../../util/utils.ts";
/** Edit the member */ /** Edit the member */
export async function editMember( export async function editMember(
+3 -3
View File
@@ -16,7 +16,7 @@ import { Collection } from "../../util/collection.ts";
export function fetchMembers( export function fetchMembers(
guildId: string, guildId: string,
shardId: number, shardId: number,
options?: RequestGuildMembers options?: RequestGuildMembers,
) { ) {
// You can request 1 member without the intent // You can request 1 member without the intent
if ( if (
@@ -41,9 +41,9 @@ function requestAllMembers(
resolve: ( resolve: (
value: value:
| Collection<string, DiscordenoMember> | Collection<string, DiscordenoMember>
| PromiseLike<Collection<string, DiscordenoMember>> | PromiseLike<Collection<string, DiscordenoMember>>,
) => void, ) => void,
options: any options: any,
): void { ): void {
throw new Error("Function not implemented."); throw new Error("Function not implemented.");
} }
+3 -3
View File
@@ -9,7 +9,7 @@ import { Collection } from "../../util/collection.ts";
export async function getMembersByQuery( export async function getMembersByQuery(
guildId: string, guildId: string,
name: string, name: string,
limit = 1 limit = 1,
) { ) {
const guild = await cacheHandlers.get("guilds", guildId); const guild = await cacheHandlers.get("guilds", guildId);
if (!guild) return; if (!guild) return;
@@ -28,9 +28,9 @@ function requestAllMembers(
resolve: ( resolve: (
value: value:
| Collection<string, DiscordenoMember> | Collection<string, DiscordenoMember>
| PromiseLike<Collection<string, DiscordenoMember>> | PromiseLike<Collection<string, DiscordenoMember>>,
) => void, ) => void,
arg3: { query: string; limit: number } arg3: { query: string; limit: number },
): void { ): void {
throw new Error("Function not implemented."); throw new Error("Function not implemented.");
} }
+2 -2
View File
@@ -13,7 +13,7 @@ import { requireBotChannelPermissions } from "../../util/permissions.ts";
/** Edit the message. */ /** Edit the message. */
export async function editMessage( export async function editMessage(
message: DiscordenoMessage, message: DiscordenoMessage,
content: string | EditMessage content: string | EditMessage,
) { ) {
if (message.author.id !== botId) { if (message.author.id !== botId) {
throw "You can only edit a message that was sent by the bot."; throw "You can only edit a message that was sent by the bot.";
@@ -32,7 +32,7 @@ export async function editMessage(
const result: DiscordMessage = await rest.runMethod( const result: DiscordMessage = await rest.runMethod(
"patch", "patch",
endpoints.CHANNEL_MESSAGE(message.channelId, message.id), endpoints.CHANNEL_MESSAGE(message.channelId, message.id),
content content,
); );
return structures.createDiscordenoMessage(result); return structures.createDiscordenoMessage(result);
+1 -1
View File
@@ -2,7 +2,7 @@ import { rest } from "../../rest/rest.ts";
import { DiscordUser } from "../../types/users/user.ts"; import { DiscordUser } from "../../types/users/user.ts";
import { Collection } from "../../util/collection.ts"; import { Collection } from "../../util/collection.ts";
import { endpoints } from "../../util/constants.ts"; import { endpoints } from "../../util/constants.ts";
import {GetReactions} from "../../types/messages/message_get_reactions.ts"; import { GetReactions } from "../../types/messages/message_get_reactions.ts";
/** Get a list of users that reacted with this emoji. */ /** Get a list of users that reacted with this emoji. */
export async function getReactions( export async function getReactions(
-1
View File
@@ -79,4 +79,3 @@ export async function executeWebhook(
return structures.createDiscordenoMessage(result as DiscordMessage); return structures.createDiscordenoMessage(result as DiscordMessage);
} }
+6 -4
View File
@@ -73,7 +73,7 @@ const baseMessage: Partial<DiscordenoMessage> = {
? { ? {
content, content,
allowedMentions: { allowedMentions: {
repliedUser: true repliedUser: true,
}, },
messageReference: { messageReference: {
messageId: this.id, messageId: this.id,
@@ -82,11 +82,13 @@ const baseMessage: Partial<DiscordenoMessage> = {
} }
: { : {
...content, ...content,
allowedMentions: { ...(content.allowedMentions || {}), repliedUser: true }, allowedMentions: {
...(content.allowedMentions || {}),
repliedUser: true,
},
messageReference: { messageReference: {
messageId: this.id, messageId: this.id,
failIfNotExists: failIfNotExists: content.messageReference?.failIfNotExists === true,
content.messageReference?.failIfNotExists === true,
}, },
}; };
+3 -2
View File
@@ -20,13 +20,14 @@ export async function resharder() {
// Begin resharding // Begin resharding
ws.maxShards = ws.botGatewayData.shards; ws.maxShards = ws.botGatewayData.shards;
// If more than 100K servers, begin switching to 16x sharding // If more than 100K servers, begin switching to 16x sharding
if (ws.maxShards && ws.useOptimalLargeBotSharding) if (ws.maxShards && ws.useOptimalLargeBotSharding) {
ws.maxShards = Math.ceil( ws.maxShards = Math.ceil(
ws.maxShards / ws.maxShards /
(ws.botGatewayData.sessionStartLimit.maxConcurrency === 1 (ws.botGatewayData.sessionStartLimit.maxConcurrency === 1
? 16 ? 16
: ws.botGatewayData.sessionStartLimit.maxConcurrency) : ws.botGatewayData.sessionStartLimit.maxConcurrency),
); );
}
ws.spawnShards(ws.firstShardId); ws.spawnShards(ws.firstShardId);
} }