fix channels.array and add guildLoaded event
This commit is contained in:
parent
b344c2e24a
commit
e3bce85f09
5 changed files with 22 additions and 17 deletions
|
@ -30,5 +30,5 @@ export const guildCreate: GatewayEventHandler = async (
|
|||
if (hasGuild === undefined) {
|
||||
// It wasn't lazy load, so emit event
|
||||
gateway.client.emit('guildCreate', guild)
|
||||
}
|
||||
} else gateway.client.emit('guildLoaded', guild)
|
||||
}
|
||||
|
|
|
@ -154,6 +154,11 @@ export interface ClientEvents {
|
|||
* @param guild The new Guild object
|
||||
*/
|
||||
guildCreate: [guild: Guild]
|
||||
/**
|
||||
* A Guild was successfully loaded.
|
||||
* @param guild The Guild object
|
||||
*/
|
||||
guildLoaded: [guild: Guild]
|
||||
/**
|
||||
* A Guild in which Client was either deleted, or bot was kicked
|
||||
* @param guild The Guild object
|
||||
|
|
|
@ -29,6 +29,7 @@ export class ChannelsManager extends BaseManager<ChannelPayload, Channel> {
|
|||
const arr = await (this.client.cache.array(
|
||||
this.cacheName
|
||||
) as ChannelPayload[])
|
||||
if (arr === undefined) return []
|
||||
const result: any[] = []
|
||||
for (const elem of arr) {
|
||||
let guild
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
import { Collection } from '../utils/collection.ts'
|
||||
import {
|
||||
connect,
|
||||
Redis,
|
||||
RedisConnectOptions
|
||||
} from '../../deps.ts'
|
||||
import { connect, Redis, RedisConnectOptions } from '../../deps.ts'
|
||||
|
||||
/**
|
||||
* ICacheAdapter is the interface to be implemented by Cache Adapters for them to be usable with Harmony.
|
||||
|
|
|
@ -7,17 +7,20 @@ client.on('debug', console.log)
|
|||
|
||||
client.on('ready', () => {
|
||||
console.log(`Logged in as ${client.user?.tag}!`)
|
||||
client.guilds.get('783319033205751809').then((guild) => {
|
||||
if (guild === undefined) return console.log('Guild not found')
|
||||
guild
|
||||
.chunk({ presences: true }, true)
|
||||
.then((guild) => {
|
||||
console.log(`Chunked guild:`, guild.id)
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(`Failed to Chunk: ${guild.id} - ${e}`)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
client.on('guildLoaded', async (guild) => {
|
||||
if (guild.id !== '783319033205751809') return
|
||||
const arr = await guild.channels.array()
|
||||
console.log(arr.length)
|
||||
guild
|
||||
.chunk({ presences: true }, true)
|
||||
.then((guild) => {
|
||||
console.log(`Chunked guild:`, guild.id)
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(`Failed to Chunk: ${guild.id} - ${e}`)
|
||||
})
|
||||
})
|
||||
|
||||
console.log('Connecting...')
|
||||
|
|
Loading…
Reference in a new issue