diff --git a/src/gateway/handlers/guildCreate.ts b/src/gateway/handlers/guildCreate.ts index bd297fa..edb858d 100644 --- a/src/gateway/handlers/guildCreate.ts +++ b/src/gateway/handlers/guildCreate.ts @@ -11,18 +11,18 @@ export const guildCreate: GatewayEventHandler = async(gateway: Gateway, d: Guild if (guild !== undefined) { // It was just lazy load, so we don't fire the event as its gonna fire for every guild bot is in await gateway.client.guilds.set(d.id, d) - if((d as any).members !== undefined) { + if ((d as any).members !== undefined) { const members = new MembersManager(gateway.client, guild) await members.fromPayload((d as any).members as MemberPayload[]) guild.members = members } - if((d as any).channels !== undefined) { + if ((d as any).channels !== undefined) { for (const ch of (d as any).channels as ChannelPayload[]) { (ch as any).guild_id = d.id await gateway.client.channels.set(ch.id, ch) } } - if((d as any).roles !== undefined) { + if ((d as any).roles !== undefined) { const roles = new RolesManager(gateway.client, guild) await roles.fromPayload((d as any).roles as RolePayload[]) guild.roles = roles @@ -31,18 +31,18 @@ export const guildCreate: GatewayEventHandler = async(gateway: Gateway, d: Guild } else { await gateway.client.guilds.set(d.id, d) guild = new Guild(gateway.client, d) - if((d as any).members !== undefined) { + if ((d as any).members !== undefined) { const members = new MembersManager(gateway.client, guild) await members.fromPayload((d as any).members as MemberPayload[]) guild.members = members } - if((d as any).channels !== undefined) { + if ((d as any).channels !== undefined) { for (const ch of (d as any).channels as ChannelPayload[]) { (ch as any).guild_id = d.id await gateway.client.channels.set(ch.id, ch) } } - if((d as any).roles !== undefined) { + if ((d as any).roles !== undefined) { const roles = new RolesManager(gateway.client, guild) await roles.fromPayload((d as any).roles as RolePayload[]) guild.roles = roles diff --git a/src/gateway/handlers/messageCreate.ts b/src/gateway/handlers/messageCreate.ts index e77382f..3e124fa 100644 --- a/src/gateway/handlers/messageCreate.ts +++ b/src/gateway/handlers/messageCreate.ts @@ -21,6 +21,6 @@ export const messageCreate: GatewayEventHandler = async ( } const mentions = new MessageMentions() const message = new Message(gateway.client, d, channel as any, user, mentions) - if(guild !== undefined) message.guild = guild + if (guild !== undefined) message.guild = guild gateway.client.emit('messageCreate', message) } diff --git a/src/gateway/handlers/resume.ts b/src/gateway/handlers/resume.ts index 0e920d1..f4948d9 100644 --- a/src/gateway/handlers/resume.ts +++ b/src/gateway/handlers/resume.ts @@ -5,6 +5,6 @@ import { Gateway, GatewayEventHandler } from '../index.ts' export const resume: GatewayEventHandler = async (gateway: Gateway, d: any) => { gateway.debug(`Session Resumed!`) gateway.client.emit('resume') - if(gateway.client.user === undefined) gateway.client.user = new User(gateway.client, await gateway.client.rest.get(CLIENT_USER()) as any) + if (gateway.client.user === undefined) gateway.client.user = new User(gateway.client, await gateway.client.rest.get(CLIENT_USER()) as any) gateway.client.emit('ready') } \ No newline at end of file diff --git a/src/gateway/index.ts b/src/gateway/index.ts index 3cd78c3..f3de6b8 100644 --- a/src/gateway/index.ts +++ b/src/gateway/index.ts @@ -227,7 +227,7 @@ class Gateway { token: this.token, properties: { $os: Deno.build.os, - $browser: 'discord.deno', + $browser: 'discord.deno', //TODO: Change lib name $device: 'discord.deno' }, compress: true, diff --git a/src/managers/BaseManager.ts b/src/managers/BaseManager.ts index 117c099..0037e22 100644 --- a/src/managers/BaseManager.ts +++ b/src/managers/BaseManager.ts @@ -30,14 +30,14 @@ export class BaseManager { return this.client.cache.delete(this.cacheName, key) } - async array(): Promise { + async array (): Promise { const arr = await (this.client.cache.array(this.cacheName) as T[]) return arr.map(e => new this.DataType(this.client, e)) as any } - async collection(): Promise> { + async collection (): Promise> { const arr = await this.array() - if(arr === undefined) return new Collection() + if (arr === undefined) return new Collection() const collection = new Collection() for (const elem of arr) { // @ts-expect-error diff --git a/src/managers/ChannelsManager.ts b/src/managers/ChannelsManager.ts index ad7e182..c9d1753 100644 --- a/src/managers/ChannelsManager.ts +++ b/src/managers/ChannelsManager.ts @@ -13,9 +13,9 @@ export class ChannelsManager extends BaseManager { // Override get method as Generic async get(key: string): Promise { const data = await this._get(key) - if(data === undefined) return + if (data === undefined) return let guild - if((data as any).guild_id !== undefined) { + if ((data as any).guild_id !== undefined) { guild = await this.client.guilds.get((data as any).guild_id) } const res = getChannelByType(this.client, data, guild) @@ -27,7 +27,7 @@ export class ChannelsManager extends BaseManager { const result: any[] = [] for(const elem of arr) { let guild - if((elem as any).guild_id !== undefined) { + if ((elem as any).guild_id !== undefined) { guild = await this.client.guilds.get((elem as any).guild_id) } result.push(getChannelByType(this.client, elem, guild)) @@ -40,7 +40,7 @@ export class ChannelsManager extends BaseManager { this.client.rest.get(CHANNEL(id)).then(async data => { this.set(id, data as ChannelPayload) let guild - if(data.guild_id !== undefined) { + if (data.guild_id !== undefined) { guild = await this.client.guilds.get(data.guild_id) } resolve(getChannelByType(this.client, data as ChannelPayload, guild)) diff --git a/src/managers/GuildChannelsManager.ts b/src/managers/GuildChannelsManager.ts index c4a5d8f..a7405b8 100644 --- a/src/managers/GuildChannelsManager.ts +++ b/src/managers/GuildChannelsManager.ts @@ -22,7 +22,7 @@ export class GuildChannelsManager extends BaseChildManager { const res = await this.parent.get(id) - if(res !== undefined && res.guild.id === this.guild.id) return res + if (res !== undefined && res.guild.id === this.guild.id) return res else return undefined } diff --git a/src/managers/GuildsManager.ts b/src/managers/GuildsManager.ts index 5c53757..6d29571 100644 --- a/src/managers/GuildsManager.ts +++ b/src/managers/GuildsManager.ts @@ -15,7 +15,7 @@ export class GuildManager extends BaseManager { this.client.rest.get(GUILD(id)).then(async (data: any) => { this.set(id, data) const guild = new Guild(this.client, data) - if((data as GuildPayload).members !== undefined) { + if ((data as GuildPayload).members !== undefined) { const members = new MembersManager(this.client, guild) await members.fromPayload((data as GuildPayload).members as MemberPayload[]) guild.members = members diff --git a/src/managers/MembersManager.ts b/src/managers/MembersManager.ts index 6d6746b..964749a 100644 --- a/src/managers/MembersManager.ts +++ b/src/managers/MembersManager.ts @@ -23,7 +23,7 @@ export class MembersManager extends BaseManager { } async fromPayload(members: MemberPayload[]): Promise { - for(const member of members) { + for (const member of members) { await this.set(member.user.id, member) } } diff --git a/src/managers/MessagesManager.ts b/src/managers/MessagesManager.ts index 52723f9..0e6aa5e 100644 --- a/src/managers/MessagesManager.ts +++ b/src/managers/MessagesManager.ts @@ -14,10 +14,10 @@ export class MessagesManager extends BaseManager { async get(key: string): Promise { const raw = await this._get(key) - if(raw === undefined) return + if (raw === undefined) return let channel = await this.client.channels.get(raw.channel_id) - if(channel === undefined) channel = await this.client.channels.fetch(raw.channel_id) - if(channel === undefined) return + if (channel === undefined) channel = await this.client.channels.fetch(raw.channel_id) + if (channel === undefined) return const author = new User(this.client, raw.author) const mentions = new MessageMentions() return new this.DataType(this.client, raw, channel, author, mentions) as any @@ -28,7 +28,7 @@ export class MessagesManager extends BaseManager { this.client.rest.get(CHANNEL_MESSAGE(channelID, id)).then(async data => { this.set(id, data as MessagePayload) let channel: any = await this.client.channels.get(channelID) - if(channel === undefined) channel = await this.client.channels.fetch(channelID) + if (channel === undefined) channel = await this.client.channels.fetch(channelID) const author = new User(this.client, (data as MessagePayload).author) await this.client.users.set(author.id, (data as MessagePayload).author) // TODO: Make this thing work (MessageMentions) diff --git a/src/managers/RolesManager.ts b/src/managers/RolesManager.ts index 6637082..a6e1d44 100644 --- a/src/managers/RolesManager.ts +++ b/src/managers/RolesManager.ts @@ -26,7 +26,7 @@ export class RolesManager extends BaseManager { } async fromPayload(roles: RolePayload[]): Promise { - for(const role of roles) { + for (const role of roles) { await this.set(role.id, role) } return true diff --git a/src/models/client.ts b/src/models/client.ts index 2a44554..09d1750 100644 --- a/src/models/client.ts +++ b/src/models/client.ts @@ -54,14 +54,14 @@ export class Client extends EventEmitter { return this } - setPresence(presence: ClientPresence | ClientActivity | ActivityGame): void { - if(presence instanceof ClientPresence) { + setPresence (presence: ClientPresence | ClientActivity | ActivityGame): void { + if (presence instanceof ClientPresence) { this.presence = presence } else this.presence = new ClientPresence(presence) this.gateway?.sendPresence(this.presence.create()) } - debug(tag: string, msg: string): void { + debug (tag: string, msg: string): void { this.emit("debug", `[${tag}] ${msg}`) } diff --git a/src/structures/message.ts b/src/structures/message.ts index 123730f..aea39bc 100644 --- a/src/structures/message.ts +++ b/src/structures/message.ts @@ -129,7 +129,7 @@ export class Message extends Base { async reply(text: string, options?: MessageOption): Promise { // TODO: Use inline replies once they're out - if(this.channel instanceof DMChannel) return this.channel.send(text, options) + if (this.channel instanceof DMChannel) return this.channel.send(text, options) return this.channel.send(`${this.author.mention}, ${text}`, options) } diff --git a/src/structures/presence.ts b/src/structures/presence.ts index b3feea0..614b1c9 100644 --- a/src/structures/presence.ts +++ b/src/structures/presence.ts @@ -38,14 +38,14 @@ export class ClientPresence { constructor(data?: ClientActivity | ClientActivityPayload | ActivityGame) { if (data !== undefined) { - if((data as ClientActivity).activity !== undefined) { + if ((data as ClientActivity).activity !== undefined) { Object.assign(this, data) - } else if((data as ClientActivityPayload).activities !== undefined) { + } else if ((data as ClientActivityPayload).activities !== undefined) { - } else if((data as ActivityGame).name !== undefined) { - if(this.activity === undefined) { + } else if ((data as ActivityGame).name !== undefined) { + if (this.activity === undefined) { this.activity = data as ActivityGame - } else if(this.activity instanceof Array) { + } else if (this.activity instanceof Array) { this.activity.push(data as ActivityGame) } else this.activity = [ this.activity, data as ActivityGame ] } @@ -76,10 +76,10 @@ export class ClientPresence { createActivity(): ActivityGame[] | null { // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions const activity = this.activity === undefined ? null : (this.activity instanceof Array ? this.activity : [this.activity]) || null - if(activity === null) return activity + if (activity === null) return activity else { activity.map(e => { - if(typeof e.type === "string") e.type = ActivityTypes[e.type] + if (typeof e.type === "string") e.type = ActivityTypes[e.type] return e }) return activity