hopefully the last dir change

This commit is contained in:
ITOH
2021-05-05 20:06:32 +02:00
parent ee2e263d63
commit 7ff0d242ff
113 changed files with 267 additions and 250 deletions
+2 -2
View File
@@ -2,7 +2,7 @@ import { rest } from "../../rest/rest.ts";
import type { CreateGuildBan } from "../../types/guilds/create_guild_ban.ts";
import { endpoints } from "../../util/constants.ts";
import { requireBotGuildPermissions } from "../../util/permissions.ts";
import { camelKeysToSnakeCase } from "../../util/utils.ts";
import { snakelize } from "../../util/utils.ts";
/** Ban a user from the guild and optionally delete previous messages sent by the user. Requires the BAN_MEMBERS permission. */
export async function ban(
@@ -15,7 +15,7 @@ export async function ban(
return await rest.runMethod<undefined>(
"put",
endpoints.GUILD_BAN(guildId, id),
camelKeysToSnakeCase(options),
snakelize(options),
);
}
-35
View File
@@ -1,35 +0,0 @@
import { rest } from "../../rest/rest.ts";
import { Errors } from "../../types/discordeno/errors.ts";
import type { User } from "../../types/users/user.ts";
import { endpoints } from "../../util/constants.ts";
import { urlToBase64 } from "../../util/utils.ts";
/** Modifies the bot's username or avatar.
* NOTE: username: if changed may cause the bot's discriminator to be randomized.
*/
export async function editBotProfile(username?: string, botAvatarURL?: string) {
// Nothing was edited
if (!username && !botAvatarURL) return;
// Check username requirements if username was provided
if (username) {
if (username.length > 32) {
throw new Error(Errors.USERNAME_MAX_LENGTH);
}
if (username.length < 2) {
throw new Error(Errors.USERNAME_MIN_LENGTH);
}
if (["@", "#", ":", "```"].some((char) => username.includes(char))) {
throw new Error(Errors.USERNAME_INVALID_CHARACTER);
}
if (["discordtag", "everyone", "here"].includes(username)) {
throw new Error(Errors.USERNAME_INVALID_USERNAME);
}
}
const avatar = botAvatarURL ? await urlToBase64(botAvatarURL) : undefined;
return await rest.runMethod<User>("patch", endpoints.USER_BOT, {
username: username?.trim(),
avatar,
});
}
+4 -4
View File
@@ -1,9 +1,9 @@
import { cacheHandlers } from "../../cache.ts";
import { rest } from "../../rest/rest.ts";
import { structures } from "../../structures/mod.ts";
import type { GuildMemberWithUser } from "../../types/guilds/guild_member.ts";
import type { ModifyGuildMember } from "../../types/guilds/modify_guild_member.ts";
import { Errors } from "../../types/discordeno/errors.ts";
import type { ModifyGuildMember } from "../../types/guilds/modify_guild_member.ts";
import type { GuildMemberWithUser } from "../../types/members/guild_member.ts";
import type { PermissionStrings } from "../../types/permissions/permission_strings.ts";
import { bigintToSnowflake } from "../../util/bigint.ts";
import { endpoints } from "../../util/constants.ts";
@@ -11,7 +11,7 @@ import {
requireBotChannelPermissions,
requireBotGuildPermissions,
} from "../../util/permissions.ts";
import { camelKeysToSnakeCase } from "../../util/utils.ts";
import { snakelize } from "../../util/utils.ts";
/** Edit the member */
export async function editMember(
@@ -73,7 +73,7 @@ export async function editMember(
const result = await rest.runMethod<GuildMemberWithUser>(
"patch",
endpoints.GUILD_MEMBER(guildId, memberId),
camelKeysToSnakeCase({
snakelize({
...options,
channelId: options.channelId
? bigintToSnowflake(options.channelId)
+2 -2
View File
@@ -1,9 +1,9 @@
import { cache } from "../../cache.ts";
import { DiscordenoMember } from "../../structures/member.ts";
import { DiscordGatewayOpcodes } from "../../types/codes/gateway_opcodes.ts";
import { DiscordGatewayIntents } from "../../types/gateway/gateway_intents.ts";
import type { RequestGuildMembers } from "../../types/guilds/request_guild_members.ts";
import { Errors } from "../../types/discordeno/errors.ts";
import { DiscordGatewayIntents } from "../../types/gateway/gateway_intents.ts";
import type { RequestGuildMembers } from "../../types/members/request_guild_members.ts";
import { Collection } from "../../util/collection.ts";
import { sendShardMessage } from "../../ws/send_shard_message.ts";
import { ws } from "../../ws/ws.ts";
+1 -1
View File
@@ -1,7 +1,7 @@
import { cacheHandlers } from "../../cache.ts";
import { rest } from "../../rest/rest.ts";
import { structures } from "../../structures/mod.ts";
import type { GuildMemberWithUser } from "../../types/guilds/guild_member.ts";
import type { GuildMemberWithUser } from "../../types/members/guild_member.ts";
import { endpoints } from "../../util/constants.ts";
/** Returns a guild member object for the specified user.
+3 -3
View File
@@ -3,10 +3,10 @@ import { cacheHandlers } from "../../cache.ts";
import { rest } from "../../rest/rest.ts";
import { DiscordenoMember } from "../../structures/member.ts";
import { structures } from "../../structures/mod.ts";
import { DiscordGatewayIntents } from "../../types/gateway/gateway_intents.ts";
import type { GuildMemberWithUser } from "../../types/guilds/guild_member.ts";
import type { ListGuildMembers } from "../../types/guilds/list_guild_members.ts";
import { Errors } from "../../types/discordeno/errors.ts";
import { DiscordGatewayIntents } from "../../types/gateway/gateway_intents.ts";
import type { GuildMemberWithUser } from "../../types/members/guild_member.ts";
import type { ListGuildMembers } from "../../types/members/list_guild_members.ts";
import { bigintToSnowflake } from "../../util/bigint.ts";
import { Collection } from "../../util/collection.ts";
import { endpoints } from "../../util/constants.ts";
+3 -3
View File
@@ -1,9 +1,9 @@
import { rest } from "../../rest/rest.ts";
import type { BeginGuildPrune } from "../../types/guilds/begin_guild_prune.ts";
import { Errors } from "../../types/discordeno/errors.ts";
import type { BeginGuildPrune } from "../../types/guilds/begin_guild_prune.ts";
import { endpoints } from "../../util/constants.ts";
import { requireBotGuildPermissions } from "../../util/permissions.ts";
import { camelKeysToSnakeCase } from "../../util/utils.ts";
import { snakelize } from "../../util/utils.ts";
/**
* Begin a prune operation. Requires the KICK_MEMBERS permission. Returns an object with one 'pruned' key indicating the number of members that were removed in the prune operation. For large guilds it's recommended to set the computePruneCount option to false, forcing 'pruned' to null. Fires multiple Guild Member Remove Gateway events.
@@ -22,7 +22,7 @@ export async function pruneMembers(
const result = await rest.runMethod<{ pruned: number }>(
"post",
endpoints.GUILD_PRUNE(guildId),
camelKeysToSnakeCase(options),
snakelize(options),
);
return result.pruned;
+2 -2
View File
@@ -2,9 +2,9 @@ import { cacheHandlers } from "../../cache.ts";
import { rest } from "../../rest/rest.ts";
import { DiscordenoMember } from "../../structures/member.ts";
import { structures } from "../../structures/mod.ts";
import type { GuildMemberWithUser } from "../../types/guilds/guild_member.ts";
import type { SearchGuildMembers } from "../../types/members/search_guild_members.ts";
import { Errors } from "../../types/discordeno/errors.ts";
import type { GuildMemberWithUser } from "../../types/members/guild_member.ts";
import type { SearchGuildMembers } from "../../types/members/search_guild_members.ts";
import { Collection } from "../../util/collection.ts";
import { endpoints } from "../../util/constants.ts";