fix many things fr
This commit is contained in:
		
							parent
							
								
									2dcce6e2bb
								
							
						
					
					
						commit
						04c4e7760b
					
				
					 7 changed files with 22 additions and 20 deletions
				
			
		|  | @ -116,11 +116,11 @@ export interface VoiceServerUpdateData { | ||||||
| // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
 | // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
 | ||||||
| export type ClientEvents = { | export type ClientEvents = { | ||||||
|   /** When Client has successfully connected to Discord */ |   /** When Client has successfully connected to Discord */ | ||||||
|   ready: [] |   ready: [shard: number] | ||||||
|   /** When a successful reconnect has been made */ |   /** When a successful reconnect has been made */ | ||||||
|   reconnect: [] |   reconnect: [shard: number] | ||||||
|   /** When a successful session resume has been done */ |   /** When a successful session resume has been done */ | ||||||
|   resumed: [] |   resumed: [shard: number] | ||||||
|   /** |   /** | ||||||
|    * When a new Channel is created |    * When a new Channel is created | ||||||
|    * @param channel New Channel object |    * @param channel New Channel object | ||||||
|  |  | ||||||
|  | @ -20,5 +20,5 @@ export const ready: GatewayEventHandler = async ( | ||||||
|     gateway.client.guilds.set(guild.id, guild) |     gateway.client.guilds.set(guild.id, guild) | ||||||
|   }) |   }) | ||||||
| 
 | 
 | ||||||
|   gateway.client.emit('ready') |   gateway.client.emit('ready', gateway.shards?.[0] ?? 0) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -8,11 +8,11 @@ export const resume: GatewayEventHandler = async ( | ||||||
|   d: Resume |   d: Resume | ||||||
| ) => { | ) => { | ||||||
|   gateway.debug(`Session Resumed!`) |   gateway.debug(`Session Resumed!`) | ||||||
|   gateway.client.emit('resumed') |   gateway.client.emit('resumed', gateway.shards?.[0] ?? 0) | ||||||
|   if (gateway.client.user === undefined) |   if (gateway.client.user === undefined) | ||||||
|     gateway.client.user = new User( |     gateway.client.user = new User( | ||||||
|       gateway.client, |       gateway.client, | ||||||
|       await gateway.client.rest.get(CLIENT_USER()) |       await gateway.client.rest.get(CLIENT_USER()) | ||||||
|     ) |     ) | ||||||
|   gateway.client.emit('ready') |   gateway.client.emit('ready', gateway.shards?.[0] ?? 0) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -179,7 +179,7 @@ export class Client extends HarmonyEventEmitter<ClientEvents> { | ||||||
|       Object.keys(this._decoratedEvents).length !== 0 |       Object.keys(this._decoratedEvents).length !== 0 | ||||||
|     ) { |     ) { | ||||||
|       Object.entries(this._decoratedEvents).forEach((entry) => { |       Object.entries(this._decoratedEvents).forEach((entry) => { | ||||||
|         this.on(entry[0] as keyof ClientEvents, entry[1]) |         this.on(entry[0] as keyof ClientEvents, entry[1].bind(this)) | ||||||
|       }) |       }) | ||||||
|       this._decoratedEvents = undefined |       this._decoratedEvents = undefined | ||||||
|     } |     } | ||||||
|  | @ -196,12 +196,6 @@ export class Client extends HarmonyEventEmitter<ClientEvents> { | ||||||
|     if (options.shard !== undefined) this.shard = options.shard |     if (options.shard !== undefined) this.shard = options.shard | ||||||
|     if (options.shardCount !== undefined) this.shardCount = options.shardCount |     if (options.shardCount !== undefined) this.shardCount = options.shardCount | ||||||
| 
 | 
 | ||||||
|     this.slash = new SlashClient({ |  | ||||||
|       id: () => this.getEstimatedID(), |  | ||||||
|       client: this, |  | ||||||
|       enabled: options.enableSlash |  | ||||||
|     }) |  | ||||||
| 
 |  | ||||||
|     this.fetchGatewayInfo = options.fetchGatewayInfo ?? true |     this.fetchGatewayInfo = options.fetchGatewayInfo ?? true | ||||||
| 
 | 
 | ||||||
|     if (this.token === undefined) { |     if (this.token === undefined) { | ||||||
|  | @ -224,6 +218,12 @@ export class Client extends HarmonyEventEmitter<ClientEvents> { | ||||||
|     if (options.restOptions !== undefined) |     if (options.restOptions !== undefined) | ||||||
|       Object.assign(restOptions, options.restOptions) |       Object.assign(restOptions, options.restOptions) | ||||||
|     this.rest = new RESTManager(restOptions) |     this.rest = new RESTManager(restOptions) | ||||||
|  | 
 | ||||||
|  |     this.slash = new SlashClient({ | ||||||
|  |       id: () => this.getEstimatedID(), | ||||||
|  |       client: this, | ||||||
|  |       enabled: options.enableSlash | ||||||
|  |     }) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   /** |   /** | ||||||
|  | @ -425,7 +425,7 @@ export function event(name?: keyof ClientEvents) { | ||||||
|   ) { |   ) { | ||||||
|     const listener = ((client as unknown) as { |     const listener = ((client as unknown) as { | ||||||
|       [name in keyof ClientEvents]: (...args: ClientEvents[name]) => any |       [name in keyof ClientEvents]: (...args: ClientEvents[name]) => any | ||||||
|     })[name ?? ((prop as unknown) as keyof ClientEvents)] |     })[(prop as unknown) as keyof ClientEvents] | ||||||
|     if (typeof listener !== 'function') |     if (typeof listener !== 'function') | ||||||
|       throw new Error('@event decorator requires a function') |       throw new Error('@event decorator requires a function') | ||||||
|     if (client._decoratedEvents === undefined) client._decoratedEvents = {} |     if (client._decoratedEvents === undefined) client._decoratedEvents = {} | ||||||
|  |  | ||||||
|  | @ -91,7 +91,7 @@ export class Extension { | ||||||
|       Object.keys(this._decoratedEvents).length !== 0 |       Object.keys(this._decoratedEvents).length !== 0 | ||||||
|     ) { |     ) { | ||||||
|       Object.entries(this._decoratedEvents).forEach((entry) => { |       Object.entries(this._decoratedEvents).forEach((entry) => { | ||||||
|         this.listen(entry[0] as keyof ClientEvents, entry[1]) |         this.listen(entry[0] as keyof ClientEvents, entry[1].bind(this)) | ||||||
|       }) |       }) | ||||||
|       this._decoratedEvents = undefined |       this._decoratedEvents = undefined | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -201,13 +201,11 @@ export class SlashBuilder { | ||||||
| 
 | 
 | ||||||
| export class SlashCommandsManager { | export class SlashCommandsManager { | ||||||
|   slash: SlashClient |   slash: SlashClient | ||||||
| 
 |   rest: RESTManager | ||||||
|   get rest(): RESTManager { |  | ||||||
|     return this.slash.rest |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|   constructor(client: SlashClient) { |   constructor(client: SlashClient) { | ||||||
|     this.slash = client |     this.slash = client | ||||||
|  |     this.rest = client.rest | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   /** Get all Global Slash Commands */ |   /** Get all Global Slash Commands */ | ||||||
|  | @ -378,7 +376,6 @@ export class SlashClient { | ||||||
|     this.id = id |     this.id = id | ||||||
|     this.client = options.client |     this.client = options.client | ||||||
|     this.token = options.token |     this.token = options.token | ||||||
|     this.commands = new SlashCommandsManager(this) |  | ||||||
|     this.publicKey = options.publicKey |     this.publicKey = options.publicKey | ||||||
| 
 | 
 | ||||||
|     if (options !== undefined) { |     if (options !== undefined) { | ||||||
|  | @ -387,12 +384,14 @@ export class SlashClient { | ||||||
| 
 | 
 | ||||||
|     if (this.client?._decoratedSlash !== undefined) { |     if (this.client?._decoratedSlash !== undefined) { | ||||||
|       this.client._decoratedSlash.forEach((e) => { |       this.client._decoratedSlash.forEach((e) => { | ||||||
|  |         e.handler = e.handler.bind(this.client) | ||||||
|         this.handlers.push(e) |         this.handlers.push(e) | ||||||
|       }) |       }) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (this._decoratedSlash !== undefined) { |     if (this._decoratedSlash !== undefined) { | ||||||
|       this._decoratedSlash.forEach((e) => { |       this._decoratedSlash.forEach((e) => { | ||||||
|  |         e.handler = e.handler.bind(this.client) | ||||||
|         this.handlers.push(e) |         this.handlers.push(e) | ||||||
|       }) |       }) | ||||||
|     } |     } | ||||||
|  | @ -409,6 +408,8 @@ export class SlashClient { | ||||||
|     this.client?.on('interactionCreate', (interaction) => |     this.client?.on('interactionCreate', (interaction) => | ||||||
|       this._process(interaction) |       this._process(interaction) | ||||||
|     ) |     ) | ||||||
|  | 
 | ||||||
|  |     this.commands = new SlashCommandsManager(this) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   getID(): string { |   getID(): string { | ||||||
|  |  | ||||||
|  | @ -7,6 +7,7 @@ export class MyClient extends Client { | ||||||
|   @event() |   @event() | ||||||
|   ready(): void { |   ready(): void { | ||||||
|     console.log(`Logged in as ${this.user?.tag}!`) |     console.log(`Logged in as ${this.user?.tag}!`) | ||||||
|  |     this.slash.commands.bulkEdit([{ name: 'send', description: 'idk' }]) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   @event('debug') |   @event('debug') | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue