change: prettier code

This commit is contained in:
TriForMine
2021-10-18 19:04:01 +00:00
committed by GitHub Action
parent 64e316647e
commit 6ece2dc106
13 changed files with 78 additions and 42 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ import {
highestRole, highestRole,
higherRolePosition, higherRolePosition,
requireBotChannelPermissions, requireBotChannelPermissions,
requireBotGuildPermissions requireBotGuildPermissions,
} from "./util/permissions.ts"; } from "./util/permissions.ts";
import { getGatewayBot } from "./helpers/misc/get_gateway_bot.ts"; import { getGatewayBot } from "./helpers/misc/get_gateway_bot.ts";
import { import {
@@ -1,8 +1,12 @@
import {Bot} from "../../bot.ts"; import { Bot } from "../../bot.ts";
/** Delete the attached integration object for the guild with this id. Requires MANAGE_GUILD permission. */ /** Delete the attached integration object for the guild with this id. Requires MANAGE_GUILD permission. */
export async function deleteIntegration(bot: Bot, guildId: bigint, id: bigint) { export async function deleteIntegration(bot: Bot, guildId: bigint, id: bigint) {
await bot.utils.requireBotGuildPermissions(bot, guildId, ["MANAGE_GUILD"]); await bot.utils.requireBotGuildPermissions(bot, guildId, ["MANAGE_GUILD"]);
return await bot.rest.runMethod<undefined>(bot.rest,"delete", bot.constants.endpoints.GUILD_INTEGRATION(guildId, id)); return await bot.rest.runMethod<undefined>(
bot.rest,
"delete",
bot.constants.endpoints.GUILD_INTEGRATION(guildId, id)
);
} }
+15 -10
View File
@@ -2,7 +2,7 @@ import type { CreateChannelInvite } from "../../types/invites/create_channel_inv
import type { InviteMetadata } from "../../types/invites/invite_metadata.ts"; import type { InviteMetadata } from "../../types/invites/invite_metadata.ts";
import { Errors } from "../../types/discordeno/errors.ts"; import { Errors } from "../../types/discordeno/errors.ts";
import { Bot } from "../../bot.ts"; import { Bot } from "../../bot.ts";
import {SnakeCasedPropertiesDeep} from "../../types/util.ts"; import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
/** Creates a new invite for this channel. Requires CREATE_INSTANT_INVITE */ /** Creates a new invite for this channel. Requires CREATE_INSTANT_INVITE */
export async function createInvite(bot: Bot, channelId: bigint, options: CreateChannelInvite = {}) { export async function createInvite(bot: Bot, channelId: bigint, options: CreateChannelInvite = {}) {
@@ -15,13 +15,18 @@ export async function createInvite(bot: Bot, channelId: bigint, options: CreateC
throw new Error(Errors.INVITE_MAX_USES_INVALID); throw new Error(Errors.INVITE_MAX_USES_INVALID);
} }
return await bot.rest.runMethod<SnakeCasedPropertiesDeep<InviteMetadata>>(bot.rest,"post", bot.constants.endpoints.CHANNEL_INVITES(channelId), { return await bot.rest.runMethod<SnakeCasedPropertiesDeep<InviteMetadata>>(
max_age: options.maxAge, bot.rest,
max_uses: options.maxUses, "post",
temporary: options.temporary, bot.constants.endpoints.CHANNEL_INVITES(channelId),
unique: options.unique, {
target_type: options.targetType, max_age: options.maxAge,
target_user_id: options.targetUserId, max_uses: options.maxUses,
target_application_id: options.targetUserId, temporary: options.temporary,
}); unique: options.unique,
target_type: options.targetType,
target_user_id: options.targetUserId,
target_application_id: options.targetUserId,
}
);
} }
+7 -3
View File
@@ -1,6 +1,6 @@
import type { InviteMetadata } from "../../types/invites/invite_metadata.ts"; import type { InviteMetadata } from "../../types/invites/invite_metadata.ts";
import {Bot} from "../../bot.ts"; import { Bot } from "../../bot.ts";
import {SnakeCasedPropertiesDeep} from "../../types/util.ts"; import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
/** Deletes an invite for the given code. Requires `MANAGE_CHANNELS` or `MANAGE_GUILD` permission */ /** Deletes an invite for the given code. Requires `MANAGE_CHANNELS` or `MANAGE_GUILD` permission */
export async function deleteInvite(bot: Bot, channelId: bigint, inviteCode: string) { export async function deleteInvite(bot: Bot, channelId: bigint, inviteCode: string) {
@@ -13,5 +13,9 @@ export async function deleteInvite(bot: Bot, channelId: bigint, inviteCode: stri
} }
} }
return await bot.rest.runMethod<SnakeCasedPropertiesDeep<InviteMetadata>>(bot.rest,"delete", bot.constants.endpoints.INVITE(inviteCode)); return await bot.rest.runMethod<SnakeCasedPropertiesDeep<InviteMetadata>>(
bot.rest,
"delete",
bot.constants.endpoints.INVITE(inviteCode)
);
} }
+7 -3
View File
@@ -1,13 +1,17 @@
import type { InviteMetadata } from "../../types/invites/invite_metadata.ts"; import type { InviteMetadata } from "../../types/invites/invite_metadata.ts";
import { Collection } from "../../util/collection.ts"; import { Collection } from "../../util/collection.ts";
import {Bot} from "../../bot.ts"; import { Bot } from "../../bot.ts";
import {SnakeCasedPropertiesDeep} from "../../types/util.ts"; import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
/** Gets the invites for this channel. Requires MANAGE_CHANNEL */ /** Gets the invites for this channel. Requires MANAGE_CHANNEL */
export async function getChannelInvites(bot: Bot, channelId: bigint) { export async function getChannelInvites(bot: Bot, channelId: bigint) {
await bot.utils.requireBotChannelPermissions(channelId, ["MANAGE_CHANNELS"]); await bot.utils.requireBotChannelPermissions(channelId, ["MANAGE_CHANNELS"]);
const result = await bot.rest.runMethod<SnakeCasedPropertiesDeep<InviteMetadata>[]>(bot.rest,"get", bot.constants.endpoints.CHANNEL_INVITES(channelId)); const result = await bot.rest.runMethod<SnakeCasedPropertiesDeep<InviteMetadata>[]>(
bot.rest,
"get",
bot.constants.endpoints.CHANNEL_INVITES(channelId)
);
return new Collection(result.map((invite) => [invite.code, invite])); return new Collection(result.map((invite) => [invite.code, invite]));
} }
+10 -6
View File
@@ -1,12 +1,16 @@
import { GetInvite } from "../../types/invites/get_invite.ts"; import { GetInvite } from "../../types/invites/get_invite.ts";
import type { InviteMetadata } from "../../types/invites/invite_metadata.ts"; import type { InviteMetadata } from "../../types/invites/invite_metadata.ts";
import {SnakeCasedPropertiesDeep} from "../../types/util.ts"; import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
import {Bot} from "../../bot.ts"; import { Bot } from "../../bot.ts";
/** Returns an invite for the given code or throws an error if the invite doesn't exists. */ /** Returns an invite for the given code or throws an error if the invite doesn't exists. */
export async function getInvite(bot: Bot, inviteCode: string, options?: GetInvite) { export async function getInvite(bot: Bot, inviteCode: string, options?: GetInvite) {
return await bot.rest.runMethod<SnakeCasedPropertiesDeep<InviteMetadata>>("get", bot.constants.endpoints.INVITE(inviteCode), { return await bot.rest.runMethod<SnakeCasedPropertiesDeep<InviteMetadata>>(
with_counts: options.withCounts, "get",
with_expiration: options.withExpiration, bot.constants.endpoints.INVITE(inviteCode),
}); {
with_counts: options.withCounts,
with_expiration: options.withExpiration,
}
);
} }
+6 -3
View File
@@ -1,13 +1,16 @@
import type { InviteMetadata } from "../../types/invites/invite_metadata.ts"; import type { InviteMetadata } from "../../types/invites/invite_metadata.ts";
import { Collection } from "../../util/collection.ts"; import { Collection } from "../../util/collection.ts";
import {SnakeCasedPropertiesDeep} from "../../types/util.ts"; import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
import {Bot} from "../../bot.ts"; import { Bot } from "../../bot.ts";
/** Get all the invites for this guild. Requires MANAGE_GUILD permission */ /** Get all the invites for this guild. Requires MANAGE_GUILD permission */
export async function getInvites(bot: Bot, guildId: bigint) { export async function getInvites(bot: Bot, guildId: bigint) {
await bot.utils.requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]); await bot.utils.requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]);
const result = await bot.rest.runMethod<SnakeCasedPropertiesDeep<InviteMetadata>[]>("get", bot.constants.endpoints.GUILD_INVITES(guildId)); const result = await bot.rest.runMethod<SnakeCasedPropertiesDeep<InviteMetadata>[]>(
"get",
bot.constants.endpoints.GUILD_INVITES(guildId)
);
return new Collection(result.map((invite) => [invite.code, invite])); return new Collection(result.map((invite) => [invite.code, invite]));
} }
+3 -3
View File
@@ -1,7 +1,7 @@
import { Errors } from "../../types/discordeno/errors.ts"; import { Errors } from "../../types/discordeno/errors.ts";
import type { User } from "../../types/users/user.ts"; import type { User } from "../../types/users/user.ts";
import {Bot} from "../../bot.ts"; import { Bot } from "../../bot.ts";
import {SnakeCasedPropertiesDeep} from "../../types/util.ts"; import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
/** Modifies the bot's username or avatar. /** Modifies the bot's username or avatar.
* NOTE: username: if changed may cause the bot's discriminator to be randomized. * NOTE: username: if changed may cause the bot's discriminator to be randomized.
@@ -27,7 +27,7 @@ export async function editBotProfile(bot: Bot, options: { username?: string; bot
const avatar = options?.botAvatarURL ? await bot.utils.urlToBase64(options?.botAvatarURL) : options?.botAvatarURL; const avatar = options?.botAvatarURL ? await bot.utils.urlToBase64(options?.botAvatarURL) : options?.botAvatarURL;
return await bot.rest.runMethod<SnakeCasedPropertiesDeep<User>>(bot,"patch", bot.constants.endpoints.USER_BOT, { return await bot.rest.runMethod<SnakeCasedPropertiesDeep<User>>(bot, "patch", bot.constants.endpoints.USER_BOT, {
username: options.username?.trim(), username: options.username?.trim(),
avatar, avatar,
}); });
+2 -2
View File
@@ -1,4 +1,4 @@
import {Bot} from "../../bot.ts"; import { Bot } from "../../bot.ts";
import { DiscordGatewayOpcodes } from "../../types/codes/gateway_opcodes.ts"; import { DiscordGatewayOpcodes } from "../../types/codes/gateway_opcodes.ts";
import type { StatusUpdate } from "../../types/gateway/status_update.ts"; import type { StatusUpdate } from "../../types/gateway/status_update.ts";
@@ -12,7 +12,7 @@ export function editBotStatus(bot: Bot, data: Omit<StatusUpdate, "afk" | "since"
since: null, since: null,
afk: false, afk: false,
activities: data.activities, activities: data.activities,
status: data.status status: data.status,
}, },
}); });
}); });
+7 -3
View File
@@ -1,8 +1,12 @@
import type { GetGatewayBot } from "../../types/gateway/get_gateway_bot.ts"; import type { GetGatewayBot } from "../../types/gateway/get_gateway_bot.ts";
import {Bot} from "../../bot.ts"; import { Bot } from "../../bot.ts";
import {SnakeCasedPropertiesDeep} from "../../types/util.ts"; import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
/** Get the bots Gateway metadata that can help during the operation of large or sharded bots. */ /** Get the bots Gateway metadata that can help during the operation of large or sharded bots. */
export async function getGatewayBot(bot: Bot) { export async function getGatewayBot(bot: Bot) {
return await bot.rest.runMethod<SnakeCasedPropertiesDeep<GetGatewayBot>>(bot.rest,"get", bot.constants.endpoints.GATEWAY_BOT); return await bot.rest.runMethod<SnakeCasedPropertiesDeep<GetGatewayBot>>(
bot.rest,
"get",
bot.constants.endpoints.GATEWAY_BOT
);
} }
+7 -3
View File
@@ -1,8 +1,12 @@
import type { User } from "../../types/users/user.ts"; import type { User } from "../../types/users/user.ts";
import {Bot} from "../../bot.ts"; import { Bot } from "../../bot.ts";
import {SnakeCasedPropertiesDeep} from "../../types/util.ts"; import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
/** This function will return the raw user payload in the rare cases you need to fetch a user directly from the API. */ /** This function will return the raw user payload in the rare cases you need to fetch a user directly from the API. */
export async function getUser(bot: Bot, userId: bigint) { export async function getUser(bot: Bot, userId: bigint) {
return await bot.rest.runMethod<SnakeCasedPropertiesDeep<User>>(bot.rest,"get", bot.constants.endpoints.USER(userId)); return await bot.rest.runMethod<SnakeCasedPropertiesDeep<User>>(
bot.rest,
"get",
bot.constants.endpoints.USER(userId)
);
} }
+6 -2
View File
@@ -1,8 +1,12 @@
import { Application } from "../../types/applications/application.ts"; import { Application } from "../../types/applications/application.ts";
import { Bot } from "../../bot.ts"; import { Bot } from "../../bot.ts";
import {SnakeCasedPropertiesDeep} from "../../types/util.ts"; import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
/** Get the applications info */ /** Get the applications info */
export async function getApplicationInfo(bot: Bot) { export async function getApplicationInfo(bot: Bot) {
return await bot.rest.runMethod<SnakeCasedPropertiesDeep<Omit<Application, "flags">>>(bot.rest,"get", bot.constants.endpoints.OAUTH2_APPLICATION); return await bot.rest.runMethod<SnakeCasedPropertiesDeep<Omit<Application, "flags">>>(
bot.rest,
"get",
bot.constants.endpoints.OAUTH2_APPLICATION
);
} }
@@ -1,6 +1,6 @@
import type { UpdateVoiceState } from "../../types/voice/update_voice_state.ts"; import type { UpdateVoiceState } from "../../types/voice/update_voice_state.ts";
import type { AtLeastOne } from "../../types/util.ts"; import type { AtLeastOne } from "../../types/util.ts";
import {Bot} from "../../bot.ts"; import { Bot } from "../../bot.ts";
/** Connect or join a voice channel inside a guild. By default, the "selfDeaf" option is true. Requires `CONNECT` and `VIEW_CHANNEL` permissions. */ /** Connect or join a voice channel inside a guild. By default, the "selfDeaf" option is true. Requires `CONNECT` and `VIEW_CHANNEL` permissions. */
export async function connectToVoiceChannel( export async function connectToVoiceChannel(