Prettified Code!

This commit is contained in:
itohatweb
2021-05-21 15:55:49 +00:00
committed by GitHub Action
parent 71a20fb0f4
commit 179add27c9
271 changed files with 889 additions and 3067 deletions
+1 -4
View File
@@ -3,8 +3,5 @@ import { endpoints } from "../../util/constants.ts";
/** Delete a guild permanently. User must be owner. Returns 204 No Content on success. Fires a Guild Delete Gateway event. */
export async function deleteGuild(guildId: bigint) {
return await rest.runMethod<undefined>(
"delete",
endpoints.GUILDS_BASE(guildId)
);
return await rest.runMethod<undefined>("delete", endpoints.GUILDS_BASE(guildId));
}
+2 -9
View File
@@ -24,18 +24,11 @@ export async function editGuild(guildId: bigint, options: ModifyGuild) {
options.splash = await urlToBase64(options.splash);
}
const result = await rest.runMethod<Guild>(
"patch",
endpoints.GUILDS_BASE(guildId),
options
);
const result = await rest.runMethod<Guild>("patch", endpoints.GUILDS_BASE(guildId), options);
const cached = await cacheHandlers.get("guilds", guildId);
return structures.createDiscordenoGuild(
result,
cached?.shardId ||
Number(
(BigInt(result.id) >> 22n % BigInt(ws.botGatewayData.shards)).toString()
)
cached?.shardId || Number((BigInt(result.id) >> 22n % BigInt(ws.botGatewayData.shards)).toString())
);
}
+2 -9
View File
@@ -4,13 +4,6 @@ import type { WelcomeScreen } from "../../types/guilds/welcome_screen.ts";
import { endpoints } from "../../util/constants.ts";
import { snakelize } from "../../util/utils.ts";
export async function editWelcomeScreen(
guildId: bigint,
options: ModifyGuildWelcomeScreen
) {
return await rest.runMethod<WelcomeScreen>(
"patch",
endpoints.GUILD_WELCOME_SCREEN(guildId),
snakelize(options)
);
export async function editWelcomeScreen(guildId: bigint, options: ModifyGuildWelcomeScreen) {
return await rest.runMethod<WelcomeScreen>("patch", endpoints.GUILD_WELCOME_SCREEN(guildId), snakelize(options));
}
+5 -13
View File
@@ -4,19 +4,11 @@ import { endpoints } from "../../util/constants.ts";
import { requireBotGuildPermissions } from "../../util/permissions.ts";
/** Modify a guild widget object for the guild. Requires the MANAGE_GUILD permission. */
export async function editWidget(
guildId: bigint,
enabled: boolean,
channelId?: string | null
) {
export async function editWidget(guildId: bigint, enabled: boolean, channelId?: string | null) {
await requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]);
return await rest.runMethod<GuildWidget>(
"patch",
endpoints.GUILD_WIDGET(guildId),
{
enabled,
channel_id: channelId,
}
);
return await rest.runMethod<GuildWidget>("patch", endpoints.GUILD_WIDGET(guildId), {
enabled,
channel_id: channelId,
});
}
+1 -4
View File
@@ -14,10 +14,7 @@ export async function getAuditLogs(guildId: bigint, options: GetGuildAuditLog) {
endpoints.GUILD_AUDIT_LOGS(guildId),
snakelize({
...options,
limit:
options.limit && options.limit >= 1 && options.limit <= 100
? options.limit
: 50,
limit: options.limit && options.limit >= 1 && options.limit <= 100 ? options.limit : 50,
})
);
}
+1 -4
View File
@@ -7,8 +7,5 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts";
export async function getBan(guildId: bigint, memberId: bigint) {
await requireBotGuildPermissions(guildId, ["BAN_MEMBERS"]);
return await rest.runMethod<Ban>(
"get",
endpoints.GUILD_BAN(guildId, memberId)
);
return await rest.runMethod<Ban>("get", endpoints.GUILD_BAN(guildId, memberId));
}
+2 -7
View File
@@ -9,12 +9,7 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts";
export async function getBans(guildId: bigint) {
await requireBotGuildPermissions(guildId, ["BAN_MEMBERS"]);
const results = await rest.runMethod<Ban[]>(
"get",
endpoints.GUILD_BANS(guildId)
);
const results = await rest.runMethod<Ban[]>("get", endpoints.GUILD_BANS(guildId));
return new Collection<bigint, Ban>(
results.map((res) => [snowflakeToBigint(res.user.id), res])
);
return new Collection<bigint, Ban>(results.map((res) => [snowflakeToBigint(res.user.id), res]));
}
+3 -7
View File
@@ -19,13 +19,9 @@ export async function getGuild(
addToCache: true,
}
) {
const result = await rest.runMethod<Guild>(
"get",
endpoints.GUILDS_BASE(guildId),
{
with_counts: options.counts,
}
);
const result = await rest.runMethod<Guild>("get", endpoints.GUILDS_BASE(guildId), {
with_counts: options.counts,
});
const guild = await structures.createDiscordenoGuild(
result,
+1 -4
View File
@@ -4,8 +4,5 @@ import { endpoints } from "../../util/constants.ts";
/** Returns the guild preview object for the given id. If the bot is not in the guild, then the guild must be Discoverable. */
export async function getGuildPreview(guildId: bigint) {
return await rest.runMethod<GuildPreview>(
"get",
endpoints.GUILD_PREVIEW(guildId)
);
return await rest.runMethod<GuildPreview>("get", endpoints.GUILD_PREVIEW(guildId));
}
+2 -9
View File
@@ -6,10 +6,7 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts";
import { snakelize } from "../../util/utils.ts";
/** Check how many members would be removed from the server in a prune operation. Requires the KICK_MEMBERS permission */
export async function getPruneCount(
guildId: bigint,
options?: GetGuildPruneCountQuery
) {
export async function getPruneCount(guildId: bigint, options?: GetGuildPruneCountQuery) {
if (options?.days && options.days < 1) throw new Error(Errors.PRUNE_MIN_DAYS);
if (options?.days && options.days > 30) {
throw new Error(Errors.PRUNE_MAX_DAYS);
@@ -17,11 +14,7 @@ export async function getPruneCount(
await requireBotGuildPermissions(guildId, ["KICK_MEMBERS"]);
const result = await rest.runMethod(
"get",
endpoints.GUILD_PRUNE(guildId),
snakelize(options ?? {})
);
const result = await rest.runMethod("get", endpoints.GUILD_PRUNE(guildId), snakelize(options ?? {}));
return result.pruned as number;
}
+2 -7
View File
@@ -5,12 +5,7 @@ import { endpoints } from "../../util/constants.ts";
/** Returns a list of voice region objects for the guild. Unlike the similar /voice route, this returns VIP servers when the guild is VIP-enabled. */
export async function getVoiceRegions(guildId: bigint) {
const result = await rest.runMethod<VoiceRegion[]>(
"get",
endpoints.GUILD_REGIONS(guildId)
);
const result = await rest.runMethod<VoiceRegion[]>("get", endpoints.GUILD_REGIONS(guildId));
return new Collection<string, VoiceRegion>(
result.map((region) => [region.id, region])
);
return new Collection<string, VoiceRegion>(result.map((region) => [region.id, region]));
}
+1 -4
View File
@@ -3,8 +3,5 @@ import type { WelcomeScreen } from "../../types/guilds/welcome_screen.ts";
import { endpoints } from "../../util/constants.ts";
export async function getWelcomeScreen(guildId: bigint) {
return await rest.runMethod<WelcomeScreen>(
"get",
endpoints.GUILD_WELCOME_SCREEN(guildId)
);
return await rest.runMethod<WelcomeScreen>("get", endpoints.GUILD_WELCOME_SCREEN(guildId));
}
+1 -4
View File
@@ -12,8 +12,5 @@ export async function getWidget(guildId: bigint, options?: { force: boolean }) {
if (!guild?.widgetEnabled) throw new Error(Errors.GUILD_WIDGET_NOT_ENABLED);
}
return await rest.runMethod<GuildWidgetDetails>(
"get",
`${endpoints.GUILD_WIDGET(guildId)}.json`
);
return await rest.runMethod<GuildWidgetDetails>("get", `${endpoints.GUILD_WIDGET(guildId)}.json`);
}
+2 -7
View File
@@ -4,17 +4,12 @@ import { Errors } from "../../types/discordeno/errors.ts";
import { endpoints } from "../../util/constants.ts";
/** Returns the widget image URL for the guild. */
export async function getWidgetImageURL(
guildId: bigint,
options?: GetGuildWidgetImageQuery & { force?: boolean }
) {
export async function getWidgetImageURL(guildId: bigint, options?: GetGuildWidgetImageQuery & { force?: boolean }) {
if (!options?.force) {
const guild = await cacheHandlers.get("guilds", guildId);
if (!guild) throw new Error(Errors.GUILD_NOT_FOUND);
if (!guild.widgetEnabled) throw new Error(Errors.GUILD_WIDGET_NOT_ENABLED);
}
return `${endpoints.GUILD_WIDGET(guildId)}.png?style=${
options?.style ?? "shield"
}`;
return `${endpoints.GUILD_WIDGET(guildId)}.png?style=${options?.style ?? "shield"}`;
}
+1 -4
View File
@@ -7,8 +7,5 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts";
export async function getWidgetSettings(guildId: bigint) {
await requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]);
return await rest.runMethod<GuildWidget>(
"get",
endpoints.GUILD_WIDGET(guildId)
);
return await rest.runMethod<GuildWidget>("get", endpoints.GUILD_WIDGET(guildId));
}
+1 -3
View File
@@ -18,9 +18,7 @@ export function guildIconURL(
? formatImageURL(
endpoints.GUILD_ICON(
id,
typeof options.icon === "string"
? options.icon
: iconBigintToHash(options.icon, options.animated ?? true)
typeof options.icon === "string" ? options.icon : iconBigintToHash(options.icon, options.animated ?? true)
),
options.size || 128,
options.format
+1 -4
View File
@@ -3,8 +3,5 @@ import { endpoints } from "../../util/constants.ts";
/** Leave a guild */
export async function leaveGuild(guildId: bigint) {
return await rest.runMethod<undefined>(
"delete",
endpoints.GUILD_LEAVE(guildId)
);
return await rest.runMethod<undefined>("delete", endpoints.GUILD_LEAVE(guildId));
}