Skip to content

Commit

Permalink
Release v0.6 (#508)
Browse files Browse the repository at this point in the history
* chore: updated example code (for djsv14)

* chore: updated dokdo version to "0.6"

* feat: displaying intents at root command
  • Loading branch information
wonderlandpark authored Aug 21, 2022
1 parent 0de2883 commit 7fbb55a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions examples/bot.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Discord = require('discord.js')
const client = new Discord.Client({ intents: ['GUILDS', 'GUILD_MEMBERS', 'GUILD_MESSAGES'] })
const { Client, GatewayIntentBits } = require('discord.js')
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] })
const config = require('./config')

const Dokdo = require('../src')
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dokdo",
"version": "0.5.1",
"version": "0.6.0",
"description": "Dokdo. Easy Discord bot debuging tool.",
"main": "./src/index.js",
"types": "./typings/index.d.ts",
Expand Down
9 changes: 6 additions & 3 deletions src/commands/main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const Discord = require('discord.js')
const { GatewayIntentBits, IntentsBitField, version: djsVersion } = require('discord.js')

const { system, DateFormatting } = require('../utils')
const { system, DateFormatting, join } = require('../utils')
const version = require('../../package.json').version

module.exports = async function (message, parent) {
let summary = `Dokdo v${version}, discord.js \`${Discord.version}\`, \`Node.js ${process.version}\` on \`${process.platform}\`\nProcess started at ${DateFormatting.relative(system.processReadyAt())}, bot was ready at ${DateFormatting.relative(parent.client.readyAt)}.\n`
const intents = new IntentsBitField(parent.client.options.intents)

let summary = `Dokdo v${version}, discord.js \`${djsVersion}\`, \`Node.js ${process.version}\` on \`${process.platform}\`\nProcess started at ${DateFormatting.relative(system.processReadyAt())}, bot was ready at ${DateFormatting.relative(parent.client.readyAt)}.\n`

summary += `\nUsing ${system.memory().rss} at this process.\n`
const cache = `${parent.client.guilds.cache.size} guild(s) and ${parent.client.users.cache.size} user(s)`
Expand All @@ -14,6 +16,7 @@ module.exports = async function (message, parent) {
summary += `Running on PID ${process.pid} for this client, and running on PID ${process.ppid} for the parent process.\n\nThis bot is sharded in ${Array.isArray(parent.client.shard.shards) ? parent.client.shard.shards.length : parent.client.shard.count} shard(s) and running in ${guilds} guild(s).\nCan see ${cache} in this client.`
} else summary += `Running on PID ${process.pid}\n\nThis bot is not sharded and can see ${cache}.`

summary += '\n' + join([GatewayIntentBits.GuildPresences, GatewayIntentBits.GuildMembers, GatewayIntentBits.MessageContent].map(u => `\`${GatewayIntentBits[u]}\` intent is ${intents.has(u) ? 'enabled' : 'disabled'}`), ', ', ' and ') + '.'
summary += `\nAverage websocket latency: ${parent.client.ws.ping}ms`

return message.channel.send(summary)
Expand Down
4 changes: 3 additions & 1 deletion src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const type = require('./type')
const isinstance = require('./isinstance')
const isGenerator = require('./isGenerator')
const regexpEscape = require('./regexpEscape')
const join = require('./join')

module.exports = {
ProcessManager,
Expand All @@ -26,5 +27,6 @@ module.exports = {
inspect,
isinstance,
isGenerator,
regexpEscape
regexpEscape,
join
}
4 changes: 4 additions & 0 deletions src/utils/join.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = function (arr, sep, lastSep) {
if (arr.length <= 1) return arr.join(sep)
return arr.reduce((text, cur, idx) => [text, cur].join(idx === arr.length - 1 ? lastSep : sep))
}

0 comments on commit 7fbb55a

Please sign in to comment.