Skip to content

Commit 7fbb55a

Browse files
Release v0.6 (#508)
* chore: updated example code (for djsv14) * chore: updated dokdo version to "0.6" * feat: displaying intents at root command
1 parent 0de2883 commit 7fbb55a

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

examples/bot.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const Discord = require('discord.js')
2-
const client = new Discord.Client({ intents: ['GUILDS', 'GUILD_MEMBERS', 'GUILD_MESSAGES'] })
1+
const { Client, GatewayIntentBits } = require('discord.js')
2+
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] })
33
const config = require('./config')
44

55
const Dokdo = require('../src')

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dokdo",
3-
"version": "0.5.1",
3+
"version": "0.6.0",
44
"description": "Dokdo. Easy Discord bot debuging tool.",
55
"main": "./src/index.js",
66
"types": "./typings/index.d.ts",

src/commands/main.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
const Discord = require('discord.js')
1+
const { GatewayIntentBits, IntentsBitField, version: djsVersion } = require('discord.js')
22

3-
const { system, DateFormatting } = require('../utils')
3+
const { system, DateFormatting, join } = require('../utils')
44
const version = require('../../package.json').version
55

66
module.exports = async function (message, parent) {
7-
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`
7+
const intents = new IntentsBitField(parent.client.options.intents)
8+
9+
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`
810

911
summary += `\nUsing ${system.memory().rss} at this process.\n`
1012
const cache = `${parent.client.guilds.cache.size} guild(s) and ${parent.client.users.cache.size} user(s)`
@@ -14,6 +16,7 @@ module.exports = async function (message, parent) {
1416
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.`
1517
} else summary += `Running on PID ${process.pid}\n\nThis bot is not sharded and can see ${cache}.`
1618

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

1922
return message.channel.send(summary)

src/utils/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const type = require('./type')
1212
const isinstance = require('./isinstance')
1313
const isGenerator = require('./isGenerator')
1414
const regexpEscape = require('./regexpEscape')
15+
const join = require('./join')
1516

1617
module.exports = {
1718
ProcessManager,
@@ -26,5 +27,6 @@ module.exports = {
2627
inspect,
2728
isinstance,
2829
isGenerator,
29-
regexpEscape
30+
regexpEscape,
31+
join
3032
}

src/utils/join.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = function (arr, sep, lastSep) {
2+
if (arr.length <= 1) return arr.join(sep)
3+
return arr.reduce((text, cur, idx) => [text, cur].join(idx === arr.length - 1 ? lastSep : sep))
4+
}

0 commit comments

Comments
 (0)