change: prettier code

This commit is contained in:
TriForMine
2021-10-21 17:38:57 +00:00
committed by GitHub Action
parent 20616e8a36
commit 3a08aa15f4
23 changed files with 76 additions and 63 deletions
+3 -3
View File
@@ -4,7 +4,7 @@ import type { Bot } from "../../bot.ts";
/** 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) {
const result = await bot.rest.runMethod<Guild>(bot.rest,"post", bot.constants.endpoints.GUILDS, {
const result = await bot.rest.runMethod<Guild>(bot.rest, "post", bot.constants.endpoints.GUILDS, {
name: options.name,
afk_channel_id: options.afkChannelId,
afk_timeout: options.afkTimeout,
@@ -15,10 +15,10 @@ export async function createGuild(bot: Bot, options: CreateGuild) {
roles: options.roles,
system_channel_flags: options.systemChannelFlags,
system_channel_id: options.systemChannelId,
verification_level: options.verificationLevel
verification_level: options.verificationLevel,
});
const guild = bot.transformers.guild(bot, {guild: result, shardId: 0});
const guild = bot.transformers.guild(bot, { guild: result, shardId: 0 });
// MANUALLY CACHE THE GUILD
await bot.cache.guilds.set(guild.id, guild);
// MANUALLY CACHE THE BOT
+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. */
export async function deleteGuild(bot: Bot, guildId: bigint) {
return await bot.rest.runMethod<undefined>(bot.rest,"delete", bot.constants.endpoints.GUILDS_BASE(guildId));
return await bot.rest.runMethod<undefined>(bot.rest, "delete", bot.constants.endpoints.GUILDS_BASE(guildId));
}
+6 -10
View File
@@ -18,16 +18,12 @@ export async function editGuild(bot: Bot, guildId: bigint, options: ModifyGuild)
options.splash = await bot.utils.urlToBase64(options.splash);
}
const result = await bot.rest.runMethod<Guild>(bot.rest,"patch", bot.constants.endpoints.GUILDS_BASE(guildId), {
});
const result = await bot.rest.runMethod<Guild>(bot.rest, "patch", bot.constants.endpoints.GUILDS_BASE(guildId), {});
const cached = await bot.cache.guilds.get(guildId);
return bot.transformers.guild(
bot,
{
guild: result,
shardId: cached?.shardId || Number((BigInt(result.id) >> 22n % BigInt(bot.gateway.botGatewayData.shards)).toString())
}
);
return bot.transformers.guild(bot, {
guild: result,
shardId:
cached?.shardId || Number((BigInt(result.id) >> 22n % BigInt(bot.gateway.botGatewayData.shards)).toString()),
});
}
+3 -3
View File
@@ -10,9 +10,9 @@ export async function editWelcomeScreen(bot: Bot, guildId: bigint, options: Modi
channel_id: welcomeScreen.channelId,
description: welcomeScreen.description,
emoji_id: welcomeScreen.emojiId,
emoji_name: welcomeScreen.emojiName
}
emoji_name: welcomeScreen.emojiName,
};
}),
description: options.description
description: options.description,
});
}
+1 -1
View File
@@ -5,7 +5,7 @@ import type { Bot } from "../../bot.ts";
export async function editWidget(bot: Bot, guildId: bigint, enabled: boolean, channelId?: string | null) {
await bot.utils.requireBotGuildPermissions(bot, guildId, ["MANAGE_GUILD"]);
return await bot.rest.runMethod<GuildWidget>(bot.rest,"patch", bot.constants.endpoints.GUILD_WIDGET(guildId), {
return await bot.rest.runMethod<GuildWidget>(bot.rest, "patch", bot.constants.endpoints.GUILD_WIDGET(guildId), {
enabled,
channel_id: channelId,
});
+6 -11
View File
@@ -6,15 +6,10 @@ import type { Bot } from "../../bot.ts";
export async function getAuditLogs(bot: Bot, guildId: bigint, options?: GetGuildAuditLog) {
await bot.utils.requireBotGuildPermissions(bot, guildId, ["VIEW_AUDIT_LOG"]);
return await bot.rest.runMethod<AuditLog>(
bot.rest,
"get",
bot.constants.endpoints.GUILD_AUDIT_LOGS(guildId),
{
user_id: options.userId,
action_type: options.actionType,
before: options.before,
limit: options?.limit && options.limit >= 1 && options.limit <= 100 ? options.limit : 50,
}
);
return await bot.rest.runMethod<AuditLog>(bot.rest, "get", bot.constants.endpoints.GUILD_AUDIT_LOGS(guildId), {
user_id: options.userId,
action_type: options.actionType,
before: options.before,
limit: options?.limit && options.limit >= 1 && options.limit <= 100 ? options.limit : 50,
});
}
@@ -3,5 +3,5 @@ import type { Bot } from "../../bot.ts";
/** Returns an array of voice regions that can be used when creating servers. */
export async function getAvailableVoiceRegions(bot: Bot) {
return await bot.rest.runMethod<VoiceRegion>(bot.rest,"get", bot.constants.endpoints.VOICE_REGIONS);
return await bot.rest.runMethod<VoiceRegion>(bot.rest, "get", bot.constants.endpoints.VOICE_REGIONS);
}
+1 -1
View File
@@ -5,5 +5,5 @@ import type { Bot } from "../../bot.ts";
export async function getBan(bot: Bot, guildId: bigint, memberId: bigint) {
await bot.utils.requireBotGuildPermissions(bot, guildId, ["BAN_MEMBERS"]);
return await bot.rest.runMethod<Ban>(bot.rest,"get", bot.constants.endpoints.GUILD_BAN(guildId, memberId));
return await bot.rest.runMethod<Ban>(bot.rest, "get", bot.constants.endpoints.GUILD_BAN(guildId, memberId));
}
+1 -1
View File
@@ -6,7 +6,7 @@ import { Collection } from "../../util/collection.ts";
export async function getBans(bot: Bot, guildId: bigint) {
await bot.utils.requireBotGuildPermissions(bot, guildId, ["BAN_MEMBERS"]);
const results = await bot.rest.runMethod<Ban[]>(bot.rest,"get", bot.constants.endpoints.GUILD_BANS(guildId));
const results = await bot.rest.runMethod<Ban[]>(bot.rest, "get", bot.constants.endpoints.GUILD_BANS(guildId));
return new Collection<bigint, Ban>(results.map((res) => [bot.transformers.snowflake(res.user.id), res]));
}
+11 -14
View File
@@ -9,24 +9,21 @@ import type { Bot } from "../../bot.ts";
* So it does not cache the guild, you must do it manually.
* */
export async function getGuild(
bot: Bot,
guildId: bigint,
options: { counts?: boolean; addToCache?: boolean } = {
counts: true,
addToCache: true,
}
bot: Bot,
guildId: bigint,
options: { counts?: boolean; addToCache?: boolean } = {
counts: true,
addToCache: true,
}
) {
const result = await bot.rest.runMethod<Guild>(bot.rest,"get", bot.constants.endpoints.GUILDS_BASE(guildId), {
const result = await bot.rest.runMethod<Guild>(bot.rest, "get", bot.constants.endpoints.GUILDS_BASE(guildId), {
with_counts: options.counts,
});
const guild = await bot.transformers.guild(
bot,
{
guild: result,
shardId: Number((BigInt(guildId) >> 22n) % BigInt(ws.botGatewayData.shards))
}
);
const guild = await bot.transformers.guild(bot, {
guild: result,
shardId: Number((BigInt(guildId) >> 22n) % BigInt(ws.botGatewayData.shards)),
});
if (options.addToCache) {
await bot.cache.guilds.set(guild.id, guild);
+1 -1
View File
@@ -3,5 +3,5 @@ import type { Bot } from "../../bot.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(bot: Bot, guildId: bigint) {
return await bot.rest.runMethod<GuildPreview>(bot.rest,"get", bot.constants.endpoints.GUILD_PREVIEW(guildId));
return await bot.rest.runMethod<GuildPreview>(bot.rest, "get", bot.constants.endpoints.GUILD_PREVIEW(guildId));
}
+11 -4
View File
@@ -10,10 +10,17 @@ export async function getPruneCount(bot: Bot, guildId: bigint, options?: GetGuil
await bot.utils.requireBotGuildPermissions(guildId, ["KICK_MEMBERS"]);
const result = await bot.rest.runMethod(bot.rest,"get", bot.constants.endpoints.GUILD_PRUNE(guildId), options ? {
days: options.days,
include_roles: options.includeRoles
} : {});
const result = await bot.rest.runMethod(
bot.rest,
"get",
bot.constants.endpoints.GUILD_PRUNE(guildId),
options
? {
days: options.days,
include_roles: options.includeRoles,
}
: {}
);
return result.pruned as number;
}
+1 -1
View File
@@ -8,5 +8,5 @@ export async function getVanityURL(bot: Bot, guildId: bigint) {
| {
code: null;
}
>(bot.rest,"get", bot.constants.endpoints.GUILD_VANITY_URL(guildId));
>(bot.rest, "get", bot.constants.endpoints.GUILD_VANITY_URL(guildId));
}
+5 -1
View File
@@ -4,7 +4,11 @@ import type { Bot } from "../../bot.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(boot: Bot, guildId: bigint) {
const result = await bot.rest.runMethod<VoiceRegion[]>(bot.rest,"get", bot.constants.endpoints.GUILD_REGIONS(guildId));
const result = await bot.rest.runMethod<VoiceRegion[]>(
bot.rest,
"get",
bot.constants.endpoints.GUILD_REGIONS(guildId)
);
return new Collection<string, VoiceRegion>(result.map((region) => [region.id, region]));
}
+5 -1
View File
@@ -2,5 +2,9 @@ import type { WelcomeScreen } from "../../types/guilds/welcome_screen.ts";
import type { Bot } from "../../bot.ts";
export async function getWelcomeScreen(bot: Bot, guildId: bigint) {
return await bot.rest.runMethod<WelcomeScreen>(bot.rset,"get", bot.constants.endpoints.GUILD_WELCOME_SCREEN(guildId));
return await bot.rest.runMethod<WelcomeScreen>(
bot.rset,
"get",
bot.constants.endpoints.GUILD_WELCOME_SCREEN(guildId)
);
}
+5 -1
View File
@@ -9,5 +9,9 @@ export async function getWidget(bot: Bot, guildId: bigint, options?: { force: bo
if (!guild?.widgetEnabled) throw new Error(bot.constants.Errors.GUILD_WIDGET_NOT_ENABLED);
}
return await bot.rest.runMethod<GuildWidgetDetails>(bot.rest,"get", `${bot.constants.endpoints.GUILD_WIDGET(guildId)}.json`);
return await bot.rest.runMethod<GuildWidgetDetails>(
bot.rest,
"get",
`${bot.constants.endpoints.GUILD_WIDGET(guildId)}.json`
);
}
+5 -1
View File
@@ -2,7 +2,11 @@ import type { Bot } from "../../bot.ts";
import type { GetGuildWidgetImageQuery } from "../../types/guilds/get_guild_widget_image.ts";
/** Returns the widget image URL for the guild. */
export async function getWidgetImageURL(bot: Bot, guildId: bigint, options?: GetGuildWidgetImageQuery & { force?: boolean }) {
export async function getWidgetImageURL(
bot: Bot,
guildId: bigint,
options?: GetGuildWidgetImageQuery & { force?: boolean }
) {
if (!options?.force) {
const guild = await bot.cache.guilds.get(guildId);
if (!guild) throw new Error(bot.constants.Errors.GUILD_NOT_FOUND);
+1 -1
View File
@@ -5,5 +5,5 @@ import type { Bot } from "../../bot.ts";
export async function getWidgetSettings(bot: Bot, guildId: bigint) {
await bot.utils.requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]);
return await bot.rest.runMethod<GuildWidget>(bot.rest,"get", bot.constants.endpoints.GUILD_WIDGET(guildId));
return await bot.rest.runMethod<GuildWidget>(bot.rest, "get", bot.constants.endpoints.GUILD_WIDGET(guildId));
}
+1 -1
View File
@@ -4,7 +4,7 @@ import type { Bot } from "../../bot.ts";
/** The full URL of the banner from Discords CDN. Undefined if no banner is set. */
export function guildBannerURL(
bot: Bot,
bot: Bot,
id: bigint,
options: {
banner?: string | bigint;
+4 -2
View File
@@ -4,7 +4,7 @@ import type { Bot } from "../../bot.ts";
/** The full URL of the icon from Discords CDN. Undefined when no icon is set. */
export function guildIconURL(
bot: Bot,
bot: Bot,
id: bigint,
options: {
icon?: string | bigint;
@@ -17,7 +17,9 @@ export function guildIconURL(
? bot.utils.formatImageURL(
bot.constants.endpoints.GUILD_ICON(
id,
typeof options.icon === "string" ? options.icon : bot.utils.iconBigintToHash(options.icon, options.animated ?? true)
typeof options.icon === "string"
? options.icon
: bot.utils.iconBigintToHash(options.icon, options.animated ?? true)
),
options.size || 128,
options.format
+1 -1
View File
@@ -4,7 +4,7 @@ import type { Bot } from "../../bot.ts";
/** The full URL of the splash from Discords CDN. Undefined if no splash is set. */
export function guildSplashURL(
bot: Bot,
bot: Bot,
id: bigint,
options: {
splash?: string | bigint;
+1 -1
View File
@@ -2,5 +2,5 @@ import type { Bot } from "../../bot.ts";
/** Leave a guild */
export async function leaveGuild(bot: Bot, guildId: bigint) {
return await bot.rest.runMethod<undefined>(bot.rest,"delete", bot.constants.endpoints.GUILD_LEAVE(guildId));
return await bot.rest.runMethod<undefined>(bot.rest, "delete", bot.constants.endpoints.GUILD_LEAVE(guildId));
}
+1 -1
View File
@@ -18,7 +18,7 @@ export async function sendDirectMessage(bot: Bot, memberId: bigint, content: str
recipient_id: memberId,
}
);
const discordenoChannel = await bot.transformers.channel(bot, {channel: dmChannelData});
const discordenoChannel = await bot.transformers.channel(bot, { channel: dmChannelData });
// Recreate the channel and add it under the users id
await bot.cache.channels.set(memberId, discordenoChannel);
dmChannel = discordenoChannel;