diff --git a/src/constants/discord.ts b/src/constants/discord.ts index 65a53084e..cac7dbc70 100644 --- a/src/constants/discord.ts +++ b/src/constants/discord.ts @@ -1,4 +1,4 @@ -let VERSION = 'v7' +let VERSION = "v7"; export const baseEndpoints = { /** Although, the version can be defaulted, keep the v6 as it can be changed to test newer versions when necessary. */ @@ -7,7 +7,7 @@ export const baseEndpoints = { }; export function changeAPIVersion(number = 7) { - VERSION = `v${number}` + VERSION = `v${number}`; } const GUILDS_BASE = (id: string) => `${baseEndpoints.BASE_URL}/guilds/${id}`; diff --git a/src/handlers/channel.ts b/src/handlers/channel.ts index 8a76d27ec..3873d6516 100644 --- a/src/handlers/channel.ts +++ b/src/handlers/channel.ts @@ -130,8 +130,11 @@ export async function sendMessage( } } - if (content.embed && !botHasChannelPermissions(channel.id, [Permissions.EMBED_LINKS])) { - throw new Error(Errors.MISSING_EMBED_LINKS) + if ( + content.embed && + !botHasChannelPermissions(channel.id, [Permissions.EMBED_LINKS]) + ) { + throw new Error(Errors.MISSING_EMBED_LINKS); } // Use ... for content length due to unicode characters and js .length handling diff --git a/src/handlers/guild.ts b/src/handlers/guild.ts index ae9e1c785..204eeb174 100644 --- a/src/handlers/guild.ts +++ b/src/handlers/guild.ts @@ -259,7 +259,7 @@ export async function createGuildRole( const roleData = result as RoleData; const role = createRole(roleData); - const guild = cache.guilds.get(guildID) + const guild = cache.guilds.get(guildID); guild?.roles.set(role.id, role); return role; } @@ -511,7 +511,7 @@ export function channelHasPermissions( const role = guild.roles.get(roleID); if (!role) return bits; - bits |= BigInt(role.permissions_new) + bits |= BigInt(role.permissions_new); return bits; }, BigInt(0)); diff --git a/src/handlers/message.ts b/src/handlers/message.ts index 3db66b81c..a4bbc734e 100644 --- a/src/handlers/message.ts +++ b/src/handlers/message.ts @@ -104,7 +104,11 @@ export function removeAllReactions(channelID: string, messageID: string) { } /** Removes all reactions for a single emoji on this message. Reaction takes the form of **name:id** for custom guild emoji, or Unicode characters. */ -export function removeReactionEmoji(channelID: string, messageID: string, reaction: string) { +export function removeReactionEmoji( + channelID: string, + messageID: string, + reaction: string, +) { if ( !botHasChannelPermissions(channelID, [Permissions.MANAGE_MESSAGES]) ) { diff --git a/src/types/channel.ts b/src/types/channel.ts index 09da44403..f175fd9b0 100644 --- a/src/types/channel.ts +++ b/src/types/channel.ts @@ -96,12 +96,12 @@ export enum ChannelTypes { export interface MessageContent { mentions?: { /** An array of allowed mention types to parse from the content. */ - parse: ("roles" | "users" | "everyone")[], + parse: ("roles" | "users" | "everyone")[]; /** Array of role_ids to mention (Max size of 100) */ - roles?: string[], + roles?: string[]; /** Array of user_ids to mention (Max size of 100) */ - users?: string[] - }, + users?: string[]; + }; /** The message contents, up to 2000 characters */ content?: string; /** A nonce that can be used for optimistic message sending. */ @@ -109,7 +109,7 @@ export interface MessageContent { /** Whether this is a TextToSpeech message */ tts?: boolean; /** The contents of the file being sent */ - file?: { blob: unknown, name: string }; + file?: { blob: unknown; name: string }; /** Embed object */ embed?: Embed; /** JSON encoded body of any additional request fields. */ diff --git a/src/types/guild.ts b/src/types/guild.ts index d48223d32..e5082469e 100644 --- a/src/types/guild.ts +++ b/src/types/guild.ts @@ -4,7 +4,7 @@ import { RoleData } from "./role.ts"; import { MemberCreatePayload } from "./member.ts"; import { Activity } from "./message.ts"; import { ClientStatusPayload } from "./presence.ts"; -import { ChannelCreatePayload } from "./channel.ts"; +import { ChannelCreatePayload, ChannelTypes } from "./channel.ts"; export interface GuildRolePayload { /** The id of the guild */ @@ -446,14 +446,6 @@ export enum AuditLogs { INTEGRATION_DELETE, } -export type ChannelTypeText = - | "text" - | "dm" - | "news" - | "voice" - | "category" - | "store"; - export interface Overwrite { /** The role or user id */ id: string; @@ -482,7 +474,7 @@ export interface RawOverwrite { export interface ChannelCreateOptions { /** The type of the channel */ - type?: ChannelTypeText; + type?: ChannelTypes; /** The channel topic. (0-1024 characters) */ topic?: string; /** The bitrate(in bits) of the voice channel. */ diff --git a/src/utils/permissions.ts b/src/utils/permissions.ts index 7ce266be1..7a458b62b 100644 --- a/src/utils/permissions.ts +++ b/src/utils/permissions.ts @@ -20,7 +20,7 @@ export function memberHasPermission( guild.roles.get(id)?.permissions_new ) .reduce((bits, permissions) => { - bits |= BigInt(permissions) + bits |= BigInt(permissions); return bits; }, BigInt(0)); @@ -41,7 +41,7 @@ export function botHasPermission(guildID: string, permissions: Permissions[]) { const permissionBits = member.roles .map((id) => guild.roles.get(id)!) .reduce((bits, data) => { - bits |= BigInt(data.permissions_new) + bits |= BigInt(data.permissions_new); return bits; }, BigInt(0));