client.ping -> client.gateway.ping

This commit is contained in:
DjDeveloperr 2021-04-17 13:47:46 +05:30
parent b324263a7b
commit ea221f8962
4 changed files with 7 additions and 10 deletions

View File

@ -59,7 +59,7 @@ client.on('ready', () => {
// Listen for event whenever a Message is sent // Listen for event whenever a Message is sent
client.on('messageCreate', (msg: Message): void => { client.on('messageCreate', (msg: Message): void => {
if (msg.content === '!ping') { if (msg.content === '!ping') {
msg.channel.send(`Pong! WS Ping: ${client.ping}`) msg.channel.send(`Pong! WS Ping: ${client.gateway.ping}`)
} }
}) })
@ -95,7 +95,7 @@ class PingCommand extends Command {
name = 'ping' name = 'ping'
execute(ctx: CommandContext) { execute(ctx: CommandContext) {
ctx.message.reply(`pong! Ping: ${ctx.client.ping}ms`) ctx.message.reply(`pong! Ping: ${ctx.client.gateway.ping}ms`)
} }
} }

View File

@ -78,8 +78,6 @@ export class Client extends HarmonyEventEmitter<ClientEvents> {
rest: RESTManager rest: RESTManager
/** User which Client logs in to, undefined until logs in */ /** User which Client logs in to, undefined until logs in */
user?: User user?: User
/** WebSocket ping of Client */
ping = 0
/** Token of the Bot/User */ /** Token of the Bot/User */
token?: string token?: string
/** Cache Adapter */ /** Cache Adapter */

View File

@ -66,6 +66,7 @@ export class Gateway extends HarmonyEventEmitter<GatewayTypedEvents> {
cache: GatewayCache cache: GatewayCache
private timedIdentify: number | null = null private timedIdentify: number | null = null
shards?: number[] shards?: number[]
ping: number = 0
constructor(client: Client, shards?: number[]) { constructor(client: Client, shards?: number[]) {
super() super()
@ -115,11 +116,9 @@ export class Gateway extends HarmonyEventEmitter<GatewayTypedEvents> {
case GatewayOpcodes.HEARTBEAT_ACK: case GatewayOpcodes.HEARTBEAT_ACK:
this.heartbeatServerResponded = true this.heartbeatServerResponded = true
this.client.ping = Date.now() - this.lastPingTimestamp this.ping = Date.now() - this.lastPingTimestamp
this.emit('ping', this.client.ping) this.emit('ping', this.ping)
this.debug( this.debug(`Received Heartbeat Ack. Ping Recognized: ${this.ping}ms`)
`Received Heartbeat Ack. Ping Recognized: ${this.client.ping}ms`
)
break break
case GatewayOpcodes.INVALID_SESSION: case GatewayOpcodes.INVALID_SESSION:

View File

@ -60,7 +60,7 @@ client.on('messageCreate', async (msg: Message) => {
console.log(`${msg.author.tag}: ${msg.content}`) console.log(`${msg.author.tag}: ${msg.content}`)
} }
if (msg.content === '!ping') { if (msg.content === '!ping') {
msg.reply(`Pong! Ping: ${client.ping}ms`) msg.reply(`Pong! Ping: ${client.gateway.ping}ms`)
} else if (msg.content === '!members') { } else if (msg.content === '!members') {
const col = await msg.guild?.members.array() const col = await msg.guild?.members.array()
const data = col const data = col