Error Fixes
This commit is contained in:
		
							parent
							
								
									2af8e15452
								
							
						
					
					
						commit
						5da856a3ad
					
				
					 10 changed files with 33 additions and 30 deletions
				
			
		|  | @ -1,3 +1,4 @@ | ||||||
|  | import { GuildChannelPayload } from "../../managers/GuildChannelsManager.ts" | ||||||
| import { Channel } from '../../structures/channel.ts' | import { Channel } from '../../structures/channel.ts' | ||||||
| import { Guild } from "../../structures/guild.ts" | import { Guild } from "../../structures/guild.ts" | ||||||
| import { ChannelPayload } from '../../types/channel.ts' | import { ChannelPayload } from '../../types/channel.ts' | ||||||
|  | @ -13,8 +14,8 @@ export const channelUpdate: GatewayEventHandler = async ( | ||||||
|   if (oldChannel !== undefined) { |   if (oldChannel !== undefined) { | ||||||
|     await gateway.client.channels.set(d.id, d) |     await gateway.client.channels.set(d.id, d) | ||||||
|     let guild: undefined | Guild; |     let guild: undefined | Guild; | ||||||
|     if(d.guild_id) { |     if((d as GuildChannelPayload).guild_id) { | ||||||
|       guild = await gateway.client.guilds.get(d.guild_id) || undefined |       guild = await gateway.client.guilds.get((d as GuildChannelPayload).guild_id) || undefined | ||||||
|     } |     } | ||||||
|     if (oldChannel.type !== d.type) { |     if (oldChannel.type !== d.type) { | ||||||
|       const channel: Channel = getChannelByType(gateway.client, d, guild) ?? oldChannel |       const channel: Channel = getChannelByType(gateway.client, d, guild) ?? oldChannel | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ import { Gateway, GatewayEventHandler } from '../index.ts' | ||||||
| import { Guild } from '../../structures/guild.ts' | import { Guild } from '../../structures/guild.ts' | ||||||
| import { User } from '../../structures/user.ts' | import { User } from '../../structures/user.ts' | ||||||
| import { GuildBanAddPayload } from '../../types/gateway.ts' | import { GuildBanAddPayload } from '../../types/gateway.ts' | ||||||
|  | import { Member } from "../../structures/member.ts" | ||||||
| 
 | 
 | ||||||
| export const guildBanAdd: GatewayEventHandler = async ( | export const guildBanAdd: GatewayEventHandler = async ( | ||||||
|   gateway: Gateway, |   gateway: Gateway, | ||||||
|  | @ -13,7 +14,7 @@ export const guildBanAdd: GatewayEventHandler = async ( | ||||||
|     new User(gateway.client, d.user) |     new User(gateway.client, d.user) | ||||||
| 
 | 
 | ||||||
|   if (guild !== undefined) { |   if (guild !== undefined) { | ||||||
|     guild.members = guild.members?.filter(member => member.id !== d.user.id) |     await guild.members.delete(user.id) | ||||||
|     gateway.client.emit('guildBanAdd', guild, user) |     gateway.client.emit('guildBanAdd', guild, user) | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -32,7 +32,7 @@ export class BaseManager<T, T2> { | ||||||
| 
 | 
 | ||||||
|   async array(): Promise<void | T2[]> { |   async array(): Promise<void | T2[]> { | ||||||
|     let arr = await (this.client.cache.array(this.cacheName) as T[]) |     let arr = await (this.client.cache.array(this.cacheName) as T[]) | ||||||
|     return arr.map(e => new this.dataType(this.client, e)) as any |     return arr.map(e => new this.DataType(this.client, e)) as any | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   async collection(): Promise<Collection<string, T2>> { |   async collection(): Promise<Collection<string, T2>> { | ||||||
|  |  | ||||||
|  | @ -12,7 +12,7 @@ export class ChannelsManager extends BaseManager<ChannelPayload, Channel> { | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   // Override get method as Generic
 |   // Override get method as Generic
 | ||||||
|   async get<T = Channel>(key: string): Promise<T | void> { |   async get<T = Channel>(key: string): Promise<T | undefined> { | ||||||
|     let data = await this._get(key) as any |     let data = await this._get(key) as any | ||||||
|     if(!data) return |     if(!data) return | ||||||
|     let guild |     let guild | ||||||
|  |  | ||||||
|  | @ -13,7 +13,7 @@ export class MessagesManager extends BaseManager<MessagePayload, Message> { | ||||||
|     super(client, 'messages', Message) |     super(client, 'messages', Message) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   async get(key: string): Promise<Message | void> { |   async get(key: string): Promise<Message | undefined> { | ||||||
|     const raw = await this._get(key) |     const raw = await this._get(key) | ||||||
|     if(!raw) return |     if(!raw) return | ||||||
|     let channel = await this.client.channels.get(raw.channel_id) |     let channel = await this.client.channels.get(raw.channel_id) | ||||||
|  | @ -21,7 +21,7 @@ export class MessagesManager extends BaseManager<MessagePayload, Message> { | ||||||
|     if(!channel) return |     if(!channel) return | ||||||
|     let author = new User(this.client, raw.author) |     let author = new User(this.client, raw.author) | ||||||
|     let mentions = new MessageMentions() |     let mentions = new MessageMentions() | ||||||
|     return new this.dataType(this.client, raw, channel, author, mentions) as any |     return new this.DataType(this.client, raw, channel, author, mentions) as any | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   fetch(channelID: string, id: string) { |   fetch(channelID: string, id: string) { | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| import { Client } from '../models/client.ts' | import { Client } from '../models/client.ts' | ||||||
| import { GuildFeatures, GuildPayload } from '../types/guild.ts' | import { GuildFeatures, GuildPayload } from '../types/guild.ts' | ||||||
| import { PresenceUpdatePayload } from '../types/gateway.ts' | import { PresenceUpdatePayload } from '../types/presence.ts' | ||||||
| import { Base } from './base.ts' | import { Base } from './base.ts' | ||||||
| import { Channel } from './channel.ts' | import { Channel } from './channel.ts' | ||||||
| import { Emoji } from './emoji.ts' | import { Emoji } from './emoji.ts' | ||||||
|  |  | ||||||
|  | @ -4,6 +4,7 @@ import { CHANNEL_MESSAGE, CHANNEL_MESSAGES } from '../types/endpoint.ts' | ||||||
| import { Channel } from './channel.ts' | import { Channel } from './channel.ts' | ||||||
| import { Message } from './message.ts' | import { Message } from './message.ts' | ||||||
| import { MessageMentions } from './MessageMentions.ts' | import { MessageMentions } from './MessageMentions.ts' | ||||||
|  | import { User } from "./user.ts" | ||||||
| 
 | 
 | ||||||
| export class TextChannel extends Channel { | export class TextChannel extends Channel { | ||||||
|   lastMessageID?: string |   lastMessageID?: string | ||||||
|  | @ -35,7 +36,7 @@ export class TextChannel extends Channel { | ||||||
|         allowed_mentions: option?.allowedMention |         allowed_mentions: option?.allowedMention | ||||||
|     }) |     }) | ||||||
| 
 | 
 | ||||||
|     return new Message(this.client, resp as any, this, this.client.user, new MessageMentions()) |     return new Message(this.client, resp as any, this, this.client.user as User, new MessageMentions()) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   async edit ( |   async edit ( | ||||||
|  |  | ||||||
|  | @ -15,10 +15,10 @@ const bot = new Client({ | ||||||
|   forceNewSession: true |   forceNewSession: true | ||||||
| }) | }) | ||||||
| 
 | 
 | ||||||
| // bot.setAdapter(new RedisCacheAdapter(bot, {
 | bot.setAdapter(new RedisCacheAdapter(bot, { | ||||||
| //   hostname: "127.0.0.1",
 |   hostname: "127.0.0.1", | ||||||
| //   port: 6379
 |   port: 6379 | ||||||
| // }))
 | })) | ||||||
| 
 | 
 | ||||||
| bot.on('ready', () => { | bot.on('ready', () => { | ||||||
|   console.log(`[Login] Logged in as ${bot.user?.tag}!`) |   console.log(`[Login] Logged in as ${bot.user?.tag}!`) | ||||||
|  |  | ||||||
|  | @ -9,7 +9,7 @@ import { UserPayload } from './user.ts' | ||||||
| /** | /** | ||||||
|  * Gateway OPcodes from Discord docs. |  * Gateway OPcodes from Discord docs. | ||||||
|  */ |  */ | ||||||
| enum GatewayOpcodes { // 문서를 확인해본 결과 Opcode 5번은 비어있다. - UnderC -
 | export enum GatewayOpcodes { // 문서를 확인해본 결과 Opcode 5번은 비어있다. - UnderC -
 | ||||||
|   DISPATCH = 0, |   DISPATCH = 0, | ||||||
|   HEARTBEAT = 1, |   HEARTBEAT = 1, | ||||||
|   IDENTIFY = 2, |   IDENTIFY = 2, | ||||||
|  | @ -26,7 +26,7 @@ enum GatewayOpcodes { // 문서를 확인해본 결과 Opcode 5번은 비어있 | ||||||
| /** | /** | ||||||
|  * Gateway Close Codes from Discord docs. |  * Gateway Close Codes from Discord docs. | ||||||
|  */ |  */ | ||||||
| enum GatewayCloseCodes { | export enum GatewayCloseCodes { | ||||||
|   UNKNOWN_ERROR = 4000, |   UNKNOWN_ERROR = 4000, | ||||||
|   UNKNOWN_OPCODE = 4001, |   UNKNOWN_OPCODE = 4001, | ||||||
|   DECODE_ERROR = 4002, |   DECODE_ERROR = 4002, | ||||||
|  | @ -43,7 +43,7 @@ enum GatewayCloseCodes { | ||||||
|   DISALLOWED_INTENTS = 4014 |   DISALLOWED_INTENTS = 4014 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| enum GatewayIntents { | export enum GatewayIntents { | ||||||
|   GUILDS = 1 << 0, |   GUILDS = 1 << 0, | ||||||
|   GUILD_MEMBERS = 1 << 1, |   GUILD_MEMBERS = 1 << 1, | ||||||
|   GUILD_BANS = 1 << 2, |   GUILD_BANS = 1 << 2, | ||||||
|  | @ -61,7 +61,7 @@ enum GatewayIntents { | ||||||
|   DIRECT_MESSAGE_TYPING = 1 << 13 |   DIRECT_MESSAGE_TYPING = 1 << 13 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| enum GatewayEvents { | export enum GatewayEvents { | ||||||
|   Ready = 'READY', |   Ready = 'READY', | ||||||
|   Resumed = 'RESUMED', |   Resumed = 'RESUMED', | ||||||
|   Reconnect = 'RECONNECT', |   Reconnect = 'RECONNECT', | ||||||
|  | @ -111,7 +111,7 @@ export interface IdentityPayload { | ||||||
|   intents: number |   intents: number | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| enum UpdateStatus { | export enum UpdateStatus { | ||||||
|   online = 'online', |   online = 'online', | ||||||
|   dnd = 'dnd', |   dnd = 'dnd', | ||||||
|   afk = 'idle', |   afk = 'idle', | ||||||
|  | @ -313,13 +313,4 @@ export interface VoiceServerUpdatePayload { | ||||||
| export interface WebhooksUpdatePayload { | export interface WebhooksUpdatePayload { | ||||||
|   guild_id: string |   guild_id: string | ||||||
|   channel_id: string |   channel_id: string | ||||||
| } | } | ||||||
| 
 |  | ||||||
| // https://discord.com/developers/docs/topics/gateway#typing-start-typing-start-event-fields
 |  | ||||||
| export { |  | ||||||
|   GatewayCloseCodes, |  | ||||||
|   GatewayOpcodes, |  | ||||||
|   GatewayIntents, |  | ||||||
|   GatewayEvents, |  | ||||||
|   UpdateStatus |  | ||||||
| } |  | ||||||
|  | @ -1,3 +1,6 @@ | ||||||
|  | import { StatusType } from "../structures/presence.ts"; | ||||||
|  | import { User } from "../structures/user.ts"; | ||||||
|  | 
 | ||||||
| export interface ClientStatus { | export interface ClientStatus { | ||||||
|   desktop?: string |   desktop?: string | ||||||
|   mobile?: string |   mobile?: string | ||||||
|  | @ -50,7 +53,7 @@ export interface ActivitySecrets { | ||||||
|   match?: string |   match?: string | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| enum ActivityFlags { | export enum ActivityFlags { | ||||||
|   INSTANCE = 1 << 0, |   INSTANCE = 1 << 0, | ||||||
|   JOIN = 1 << 1, |   JOIN = 1 << 1, | ||||||
|   SPECTATE = 1 << 2, |   SPECTATE = 1 << 2, | ||||||
|  | @ -59,4 +62,10 @@ enum ActivityFlags { | ||||||
|   PLAY = 1 << 5 |   PLAY = 1 << 5 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export { ActivityFlags } | export interface PresenceUpdatePayload { | ||||||
|  |   user: User | ||||||
|  |   guild_id: string | ||||||
|  |   status: StatusType | ||||||
|  |   activities: ActivityPayload | ||||||
|  |   client_status: ClientStatus | ||||||
|  | } | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue