docs: Update desired properties docs (#3940)

* Update docs for desired properties

* Update examples to use createBot desiredProperties

The BigBot and reaction roles examples use the Discordeno CLI

* Migrate examples to v19 stable

* Docs work
This commit is contained in:
Fleny
2024-11-19 16:40:01 -06:00
committed by GitHub
parent 54a7463dbb
commit 4939822434
44 changed files with 1369 additions and 1103 deletions
+6 -6
View File
@@ -13,14 +13,14 @@
"setup-dd": "" "setup-dd": ""
}, },
"dependencies": { "dependencies": {
"@discordeno/bot": "19.0.0-next.92bf166", "@discordeno/bot": "19.0.0",
"dd-cache-proxy": "^2.1.1", "dd-cache-proxy": "^2.3.0",
"dotenv": "^16.4.5" "dotenv": "^16.4.5"
}, },
"devDependencies": { "devDependencies": {
"@swc/cli": "^0.3.12", "@swc/cli": "^0.5.0",
"@swc/core": "^1.6.3", "@swc/core": "^1.9.2",
"@types/node": "^20.14.6", "@types/node": "^22.9.0",
"typescript": "^5.5.2" "typescript": "^5.6.3"
} }
} }
+61 -39
View File
@@ -1,49 +1,71 @@
import { Intents, LogDepth, createBot, type logger as discordenoLogger } from '@discordeno/bot' import { type Collection, Intents, LogDepth, createBot, type logger as discordenoLogger } from '@discordeno/bot'
import { createProxyCache } from 'dd-cache-proxy' import { createProxyCache } from 'dd-cache-proxy'
import { configs } from './config.js' import { configs } from './config.js'
export const bot = createProxyCache( const rawBot = createBot({
createBot({ token: configs.token,
token: configs.token, intents: Intents.Guilds,
intents: Intents.Guilds, desiredProperties: {
}), interaction: {
{ id: true,
desiredProps: { type: true,
guilds: ['id', 'name', 'roles'], data: true,
roles: ['id', 'guildId', 'permissions'], token: true,
guildId: true,
member: true,
}, },
cacheInMemory: { guild: {
guilds: true, id: true,
name: true,
roles: true, roles: true,
default: false, ownerId: true,
},
role: {
id: true,
guildId: true,
permissions: true,
},
member: {
id: true,
roles: true,
},
channel: {
id: true,
},
user: {
id: true,
username: true,
discriminator: true,
}, },
}, },
) })
// TODO: remove this type hack when dd-cache-proxy fixes support for v19
// @ts-expect-error
export const bot = createProxyCache(rawBot, {
desiredProps: {
guilds: ['id', 'name', 'roles'],
roles: ['id', 'guildId', 'permissions'],
},
cacheInMemory: {
guilds: true,
roles: true,
default: false,
},
}) as CacheBot
export type CacheBot = typeof rawBot & {
cache: {
guild: {
memory: Collection<bigint, typeof rawBot.transformers.$inferredTypes.guild>
get: (guildId: bigint) => typeof rawBot.transformers.$inferredTypes.guild
}
role: {
memory: Collection<bigint, typeof rawBot.transformers.$inferredTypes.role>
get: (roleId: bigint) => typeof rawBot.transformers.$inferredTypes.role
}
}
}
// By default, bot.logger will use an instance of the logger from @discordeno/bot, this logger supports depth and we need to change it, so we need to say to TS that we know what we are doing with as // By default, bot.logger will use an instance of the logger from @discordeno/bot, this logger supports depth and we need to change it, so we need to say to TS that we know what we are doing with as
;(bot.logger as typeof discordenoLogger).setDepth(LogDepth.Full) ;(bot.logger as typeof discordenoLogger).setDepth(LogDepth.Full)
// Setup desired properties
bot.transformers.desiredProperties.interaction.id = true
bot.transformers.desiredProperties.interaction.type = true
bot.transformers.desiredProperties.interaction.data = true
bot.transformers.desiredProperties.interaction.token = true
bot.transformers.desiredProperties.interaction.guildId = true
bot.transformers.desiredProperties.interaction.member = true
bot.transformers.desiredProperties.guild.id = true
bot.transformers.desiredProperties.guild.name = true
bot.transformers.desiredProperties.guild.roles = true
bot.transformers.desiredProperties.role.id = true
bot.transformers.desiredProperties.role.guildId = true
bot.transformers.desiredProperties.role.permissions = true
bot.transformers.desiredProperties.member.id = true
bot.transformers.desiredProperties.member.roles = true
bot.transformers.desiredProperties.channel.id = true
bot.transformers.desiredProperties.user.id = true
bot.transformers.desiredProperties.user.username = true
bot.transformers.desiredProperties.user.discriminator = true
+3 -2
View File
@@ -1,4 +1,5 @@
import { type ApplicationCommandOption, type ApplicationCommandTypes, Collection, type Interaction } from '@discordeno/bot' import { type ApplicationCommandOption, type ApplicationCommandTypes, Collection } from '@discordeno/bot'
import type { bot } from './bot.js'
export const commands = new Collection<string, Command>() export const commands = new Collection<string, Command>()
@@ -16,5 +17,5 @@ export interface Command {
/** The options for this command */ /** The options for this command */
options?: ApplicationCommandOption[] options?: ApplicationCommandOption[]
/** This will be executed when the command is run. */ /** This will be executed when the command is run. */
execute: (interaction: Interaction, options: Record<string, unknown>) => unknown execute: (interaction: typeof bot.transformers.$inferredTypes.interaction, options: Record<string, unknown>) => unknown
} }
+1 -1
View File
@@ -30,7 +30,7 @@ createCommand({
// Type based on the options declared above // Type based on the options declared above
const { user, reason } = options as { user: UserResolved; reason?: string } const { user, reason } = options as { user: UserResolved; reason?: string }
const guild = await bot.cache.guilds.get(interaction.guildId) const guild = await bot.cache.guild.get(interaction.guildId)
if (!guild) { if (!guild) {
await interaction.respond('An error has occurred') await interaction.respond('An error has occurred')
@@ -12,6 +12,7 @@ bot.events.interactionCreate = async (interaction) => {
return return
} }
// @ts-expect-error commandOptionsParser requires the entire Interaction object, this is a bug in @discordeno/bot
const options = commandOptionsParser(interaction) const options = commandOptionsParser(interaction)
try { try {
+6 -2
View File
@@ -1,7 +1,11 @@
import assert from 'node:assert' import assert from 'node:assert'
import { BitwisePermissionFlags, type Guild, type Member } from '@discordeno/bot' import { BitwisePermissionFlags } from '@discordeno/bot'
import type { bot } from '../bot.js'
export async function calculateMemberPermissions(guild: Guild, member: Member): Promise<bigint> { export async function calculateMemberPermissions(
guild: typeof bot.transformers.$inferredTypes.guild,
member: typeof bot.transformers.$inferredTypes.member,
) {
if (member.id === guild.ownerId) return 8n if (member.id === guild.ownerId) return 8n
let permissions = guild.roles.get(guild.id)?.permissions.bitfield let permissions = guild.roles.get(guild.id)?.permissions.bitfield
+131 -113
View File
@@ -5,54 +5,56 @@ __metadata:
version: 8 version: 8
cacheKey: 10 cacheKey: 10
"@discordeno/bot@npm:19.0.0-next.92bf166": "@discordeno/bot@npm:19.0.0":
version: 19.0.0-next.92bf166 version: 19.0.0
resolution: "@discordeno/bot@npm:19.0.0-next.92bf166" resolution: "@discordeno/bot@npm:19.0.0"
dependencies: dependencies:
"@discordeno/gateway": "npm:19.0.0-next.92bf166" "@discordeno/gateway": "npm:19.0.0"
"@discordeno/rest": "npm:19.0.0-next.92bf166" "@discordeno/rest": "npm:19.0.0"
"@discordeno/types": "npm:19.0.0-next.92bf166" "@discordeno/types": "npm:19.0.0"
"@discordeno/utils": "npm:19.0.0-next.92bf166" "@discordeno/utils": "npm:19.0.0"
checksum: 3020e74c774eae34307d434ad38f983e90839dc5fad7578f3cda4fba6c1efb7a22c4f4cdcfff58c54b62cc14976ad974256955d5117e490f78ec9e835e02c682 checksum: 86ac4cd61761c1b3c3fa82db08742dcdba18ffb1b6042455c8a5e8cdd02231543c3c2d43dfb29084d44034cafebdc6ab51969c5930281ab2be83d5b159b69726
languageName: node languageName: node
linkType: hard linkType: hard
"@discordeno/gateway@npm:19.0.0-next.92bf166": "@discordeno/gateway@npm:19.0.0":
version: 19.0.0-next.92bf166 version: 19.0.0
resolution: "@discordeno/gateway@npm:19.0.0-next.92bf166" resolution: "@discordeno/gateway@npm:19.0.0"
dependencies: dependencies:
"@discordeno/types": "npm:19.0.0-next.92bf166" "@discordeno/types": "npm:19.0.0"
"@discordeno/utils": "npm:19.0.0-next.92bf166" "@discordeno/utils": "npm:19.0.0"
ws: "npm:^8.16.0" fzstd: "npm:^0.1.1"
checksum: 6a11ca7a4cb98f48726664d0baa27d04e26342bf94d6e439494e462636af20d17b567e9d3e2e478465aabcecb98a21e54b860b39b9f1022eef922e76d947ddcb ws: "npm:^8.18.0"
dependenciesMeta:
fzstd:
optional: true
checksum: 241ec9981bf47ff894990889477fbc1ce91361648534189361e9dca4d927aba15c941604da29ba135cb20871fac7e82e5cc1eed1df6ef3d86bbcdfdca3448649
languageName: node languageName: node
linkType: hard linkType: hard
"@discordeno/rest@npm:19.0.0-next.92bf166": "@discordeno/rest@npm:19.0.0":
version: 19.0.0-next.92bf166 version: 19.0.0
resolution: "@discordeno/rest@npm:19.0.0-next.92bf166" resolution: "@discordeno/rest@npm:19.0.0"
dependencies: dependencies:
"@discordeno/types": "npm:19.0.0-next.92bf166" "@discordeno/types": "npm:19.0.0"
"@discordeno/utils": "npm:19.0.0-next.92bf166" "@discordeno/utils": "npm:19.0.0"
dotenv: "npm:^16.4.5" checksum: e1ce6c092566e58c5d407a5fee7c6c38f988251abcbaaf14beaa084691b4c52dc4f6c54f46974735090fafe174b1914374edd074bffd441e11d76851575a136f
checksum: 45f6ba4791003b77c883e991ad348597197d70e25e335b8628a03bd2effa8e2047a2f987f4c0b6ee8b17c01f77055d7a1ddc9f5350eb8f1c8ff8c8d39f91d787
languageName: node languageName: node
linkType: hard linkType: hard
"@discordeno/types@npm:19.0.0-next.92bf166": "@discordeno/types@npm:19.0.0":
version: 19.0.0-next.92bf166 version: 19.0.0
resolution: "@discordeno/types@npm:19.0.0-next.92bf166" resolution: "@discordeno/types@npm:19.0.0"
checksum: f88e78a18e51c179b94ef14e8bcdd6b5e6c5f25bdd6c4308bec121e5e59533612b36ed0e7a447daedc009053e1e30c6c8e13b2276bb1ce7e2f840ff58473a2ef checksum: aaf832d6510b7aa0ead75bd5c1d1990f3a77fa980d40122d6d092abc571280aed6864b10fdda705d70bd7ba73961f4b3a0ee28c6b7cabb09595574f65fcfd61c
languageName: node languageName: node
linkType: hard linkType: hard
"@discordeno/utils@npm:19.0.0-next.92bf166": "@discordeno/utils@npm:19.0.0":
version: 19.0.0-next.92bf166 version: 19.0.0
resolution: "@discordeno/utils@npm:19.0.0-next.92bf166" resolution: "@discordeno/utils@npm:19.0.0"
dependencies: dependencies:
"@discordeno/types": "npm:19.0.0-next.92bf166" "@discordeno/types": "npm:19.0.0"
tweetnacl: "npm:^1.0.3" checksum: b2d430099672cfb8b68d6a9bd12803cd69cb909dc1f368d8305a4bb1067499babff05997a29599b51029d0add435bea4a03929140abf77dd83e1741baaa37855
checksum: 7962a057ba5908936e4224df70b9ceaffcb8ec7ad220a999b36fc0601365b380bb0de01b6adfa4c36250247e3d15e22215fc63bbe3634b932434411c5f4ca13d
languageName: node languageName: node
linkType: hard linkType: hard
@@ -149,9 +151,9 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/cli@npm:^0.3.12": "@swc/cli@npm:^0.5.0":
version: 0.3.12 version: 0.5.0
resolution: "@swc/cli@npm:0.3.12" resolution: "@swc/cli@npm:0.5.0"
dependencies: dependencies:
"@mole-inc/bin-wrapper": "npm:^8.0.1" "@mole-inc/bin-wrapper": "npm:^8.0.1"
"@swc/counter": "npm:^0.1.3" "@swc/counter": "npm:^0.1.3"
@@ -172,96 +174,96 @@ __metadata:
spack: bin/spack.js spack: bin/spack.js
swc: bin/swc.js swc: bin/swc.js
swcx: bin/swcx.js swcx: bin/swcx.js
checksum: fee260434fad8eed0328f4db17f42ce0864b93b90fcb02f3f0eb3aad994b5a6ae4bfdfb6d2329377e0cd8d07adc61cca42e290bf0005c1ab4d004d4a0b152db4 checksum: 033b682f1c25c8fae731414d2a463a0e455452bf9349c025cd88ea63ee1e5a589032eb206063fd925daf12065c9f1e5b4680cef50cc24674681c4d2583b7dca0
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-darwin-arm64@npm:1.6.3": "@swc/core-darwin-arm64@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-darwin-arm64@npm:1.6.3" resolution: "@swc/core-darwin-arm64@npm:1.9.2"
conditions: os=darwin & cpu=arm64 conditions: os=darwin & cpu=arm64
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-darwin-x64@npm:1.6.3": "@swc/core-darwin-x64@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-darwin-x64@npm:1.6.3" resolution: "@swc/core-darwin-x64@npm:1.9.2"
conditions: os=darwin & cpu=x64 conditions: os=darwin & cpu=x64
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-linux-arm-gnueabihf@npm:1.6.3": "@swc/core-linux-arm-gnueabihf@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-linux-arm-gnueabihf@npm:1.6.3" resolution: "@swc/core-linux-arm-gnueabihf@npm:1.9.2"
conditions: os=linux & cpu=arm conditions: os=linux & cpu=arm
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-linux-arm64-gnu@npm:1.6.3": "@swc/core-linux-arm64-gnu@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-linux-arm64-gnu@npm:1.6.3" resolution: "@swc/core-linux-arm64-gnu@npm:1.9.2"
conditions: os=linux & cpu=arm64 & libc=glibc conditions: os=linux & cpu=arm64 & libc=glibc
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-linux-arm64-musl@npm:1.6.3": "@swc/core-linux-arm64-musl@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-linux-arm64-musl@npm:1.6.3" resolution: "@swc/core-linux-arm64-musl@npm:1.9.2"
conditions: os=linux & cpu=arm64 & libc=musl conditions: os=linux & cpu=arm64 & libc=musl
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-linux-x64-gnu@npm:1.6.3": "@swc/core-linux-x64-gnu@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-linux-x64-gnu@npm:1.6.3" resolution: "@swc/core-linux-x64-gnu@npm:1.9.2"
conditions: os=linux & cpu=x64 & libc=glibc conditions: os=linux & cpu=x64 & libc=glibc
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-linux-x64-musl@npm:1.6.3": "@swc/core-linux-x64-musl@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-linux-x64-musl@npm:1.6.3" resolution: "@swc/core-linux-x64-musl@npm:1.9.2"
conditions: os=linux & cpu=x64 & libc=musl conditions: os=linux & cpu=x64 & libc=musl
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-win32-arm64-msvc@npm:1.6.3": "@swc/core-win32-arm64-msvc@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-win32-arm64-msvc@npm:1.6.3" resolution: "@swc/core-win32-arm64-msvc@npm:1.9.2"
conditions: os=win32 & cpu=arm64 conditions: os=win32 & cpu=arm64
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-win32-ia32-msvc@npm:1.6.3": "@swc/core-win32-ia32-msvc@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-win32-ia32-msvc@npm:1.6.3" resolution: "@swc/core-win32-ia32-msvc@npm:1.9.2"
conditions: os=win32 & cpu=ia32 conditions: os=win32 & cpu=ia32
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-win32-x64-msvc@npm:1.6.3": "@swc/core-win32-x64-msvc@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-win32-x64-msvc@npm:1.6.3" resolution: "@swc/core-win32-x64-msvc@npm:1.9.2"
conditions: os=win32 & cpu=x64 conditions: os=win32 & cpu=x64
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core@npm:^1.6.3": "@swc/core@npm:^1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core@npm:1.6.3" resolution: "@swc/core@npm:1.9.2"
dependencies: dependencies:
"@swc/core-darwin-arm64": "npm:1.6.3" "@swc/core-darwin-arm64": "npm:1.9.2"
"@swc/core-darwin-x64": "npm:1.6.3" "@swc/core-darwin-x64": "npm:1.9.2"
"@swc/core-linux-arm-gnueabihf": "npm:1.6.3" "@swc/core-linux-arm-gnueabihf": "npm:1.9.2"
"@swc/core-linux-arm64-gnu": "npm:1.6.3" "@swc/core-linux-arm64-gnu": "npm:1.9.2"
"@swc/core-linux-arm64-musl": "npm:1.6.3" "@swc/core-linux-arm64-musl": "npm:1.9.2"
"@swc/core-linux-x64-gnu": "npm:1.6.3" "@swc/core-linux-x64-gnu": "npm:1.9.2"
"@swc/core-linux-x64-musl": "npm:1.6.3" "@swc/core-linux-x64-musl": "npm:1.9.2"
"@swc/core-win32-arm64-msvc": "npm:1.6.3" "@swc/core-win32-arm64-msvc": "npm:1.9.2"
"@swc/core-win32-ia32-msvc": "npm:1.6.3" "@swc/core-win32-ia32-msvc": "npm:1.9.2"
"@swc/core-win32-x64-msvc": "npm:1.6.3" "@swc/core-win32-x64-msvc": "npm:1.9.2"
"@swc/counter": "npm:^0.1.3" "@swc/counter": "npm:^0.1.3"
"@swc/types": "npm:^0.1.8" "@swc/types": "npm:^0.1.15"
peerDependencies: peerDependencies:
"@swc/helpers": "*" "@swc/helpers": "*"
dependenciesMeta: dependenciesMeta:
@@ -288,7 +290,7 @@ __metadata:
peerDependenciesMeta: peerDependenciesMeta:
"@swc/helpers": "@swc/helpers":
optional: true optional: true
checksum: b4c84a083ecabb0280ba53dffa65a5a575321de94081ad52bd12027fe3b5c8957978f2211b6036e2e28d904dd046fca238106c2106b32d02b752808a51193d35 checksum: 6793f2014a016f90b1c41a695f6d3a14d574e129e78f651fe3d6dbacbc6d0836ab7a7eb445d873a302b060b25ae34c4e09d0f94574a71da47c6424c5fa58aa10
languageName: node languageName: node
linkType: hard linkType: hard
@@ -299,12 +301,12 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/types@npm:^0.1.8": "@swc/types@npm:^0.1.15":
version: 0.1.8 version: 0.1.15
resolution: "@swc/types@npm:0.1.8" resolution: "@swc/types@npm:0.1.15"
dependencies: dependencies:
"@swc/counter": "npm:^0.1.3" "@swc/counter": "npm:^0.1.3"
checksum: 2d1cda35116e03714137c1c37f4493efe0e26e88285ecc9dcdf6256a77984e367ea7b5f31d650f110fdcfd6ac53dff3ec77f841787ca328d2efa7b07ef1ac318 checksum: d8bf063aeebac51290d1edf0cec52e2e5b5afced0dc6933510a86947e10f0f77976bc14c3efb5e8f265a9cbdeb0929e00e44b2f82c6d0f273997c5029417b769
languageName: node languageName: node
linkType: hard linkType: hard
@@ -352,7 +354,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@types/node@npm:*, @types/node@npm:^20.14.6": "@types/node@npm:*":
version: 20.14.6 version: 20.14.6
resolution: "@types/node@npm:20.14.6" resolution: "@types/node@npm:20.14.6"
dependencies: dependencies:
@@ -361,6 +363,15 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@types/node@npm:^22.9.0":
version: 22.9.0
resolution: "@types/node@npm:22.9.0"
dependencies:
undici-types: "npm:~6.19.8"
checksum: a7df3426891868b0f5fb03e46aeddd8446178233521c624a44531c92a040cf08a82d8235f7e1e02af731fd16984665d4d71f3418caf9c2788313b10f040d615d
languageName: node
linkType: hard
"@types/responselike@npm:^1.0.0": "@types/responselike@npm:^1.0.0":
version: 1.0.3 version: 1.0.3
resolution: "@types/responselike@npm:1.0.3" resolution: "@types/responselike@npm:1.0.3"
@@ -612,22 +623,22 @@ __metadata:
version: 0.0.0-use.local version: 0.0.0-use.local
resolution: "dd-advanced-bot@workspace:." resolution: "dd-advanced-bot@workspace:."
dependencies: dependencies:
"@discordeno/bot": "npm:19.0.0-next.92bf166" "@discordeno/bot": "npm:19.0.0"
"@swc/cli": "npm:^0.3.12" "@swc/cli": "npm:^0.5.0"
"@swc/core": "npm:^1.6.3" "@swc/core": "npm:^1.9.2"
"@types/node": "npm:^20.14.6" "@types/node": "npm:^22.9.0"
dd-cache-proxy: "npm:^2.1.1" dd-cache-proxy: "npm:^2.3.0"
dotenv: "npm:^16.4.5" dotenv: "npm:^16.4.5"
typescript: "npm:^5.5.2" typescript: "npm:^5.6.3"
languageName: unknown languageName: unknown
linkType: soft linkType: soft
"dd-cache-proxy@npm:^2.1.1": "dd-cache-proxy@npm:^2.3.0":
version: 2.1.1 version: 2.3.0
resolution: "dd-cache-proxy@npm:2.1.1" resolution: "dd-cache-proxy@npm:2.3.0"
peerDependencies: peerDependencies:
"@discordeno/bot": 19.0.0-next.d69e537 "@discordeno/bot": 19.0.0-next.b85c6d5
checksum: 082234277fd0dc91477b0ac4a938aea40b8d3ffa60e7e458ce570b2f4c919671ecd5b601f7ff6c6157a5e4e5eaa3786e6a1884cccb020a938cb76e4e300f0f72 checksum: eda7d43717567b7836208c9690bbc0a547179ff7319daf5ccc08c83bc44d481854bcb474075021646ddc8560015d8b0d5e5c66f72ace67f858484b805a40f5a1
languageName: node languageName: node
linkType: hard linkType: hard
@@ -890,6 +901,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"fzstd@npm:^0.1.1":
version: 0.1.1
resolution: "fzstd@npm:0.1.1"
checksum: 455b968aeb764f06d9c39a5c8b45eefd645f7ee9129896e890eafb8ab367482f8495de12907021a32f6544494305a42a2056c30c63efac06181e6efcdab3fe78
languageName: node
linkType: hard
"get-stream@npm:^3.0.0": "get-stream@npm:^3.0.0":
version: 3.0.0 version: 3.0.0
resolution: "get-stream@npm:3.0.0" resolution: "get-stream@npm:3.0.0"
@@ -1973,30 +1991,23 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"tweetnacl@npm:^1.0.3": "typescript@npm:^5.6.3":
version: 1.0.3 version: 5.6.3
resolution: "tweetnacl@npm:1.0.3" resolution: "typescript@npm:5.6.3"
checksum: ca122c2f86631f3c0f6d28efb44af2a301d4a557a62a3e2460286b08e97567b258c2212e4ad1cfa22bd6a57edcdc54ba76ebe946847450ab0999e6d48ccae332
languageName: node
linkType: hard
"typescript@npm:^5.5.2":
version: 5.5.2
resolution: "typescript@npm:5.5.2"
bin: bin:
tsc: bin/tsc tsc: bin/tsc
tsserver: bin/tsserver tsserver: bin/tsserver
checksum: 9118b20f248e76b0dbff8737fef65dfa89d02668d4e633d2c5ceac99033a0ca5e8a1c1a53bc94da68e8f67677a88f318663dde859c9e9a09c1e116415daec2ba checksum: c328e418e124b500908781d9f7b9b93cf08b66bf5936d94332b463822eea2f4e62973bfb3b8a745fdc038785cb66cf59d1092bac3ec2ac6a3e5854687f7833f1
languageName: node languageName: node
linkType: hard linkType: hard
"typescript@patch:typescript@npm%3A^5.5.2#optional!builtin<compat/typescript>": "typescript@patch:typescript@npm%3A^5.6.3#optional!builtin<compat/typescript>":
version: 5.5.2 version: 5.6.3
resolution: "typescript@patch:typescript@npm%3A5.5.2#optional!builtin<compat/typescript>::version=5.5.2&hash=e012d7" resolution: "typescript@patch:typescript@npm%3A5.6.3#optional!builtin<compat/typescript>::version=5.6.3&hash=e012d7"
bin: bin:
tsc: bin/tsc tsc: bin/tsc
tsserver: bin/tsserver tsserver: bin/tsserver
checksum: 28b3de2ddaf63a7620e7ddbe5d377af71ce93ecc558c41bf0e3d88661d8e6e7aa6c7739164fef98055f69819e41faca49252938ef3633a3dff2734cca6a9042e checksum: dc4bec403cd33a204b655b1152a096a08e7bad2c931cb59ef8ff26b6f2aa541bf98f09fc157958a60c921b1983a8dde9a85b692f9de60fa8f574fd131e3ae4dd
languageName: node languageName: node
linkType: hard linkType: hard
@@ -2007,6 +2018,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"undici-types@npm:~6.19.8":
version: 6.19.8
resolution: "undici-types@npm:6.19.8"
checksum: cf0b48ed4fc99baf56584afa91aaffa5010c268b8842f62e02f752df209e3dea138b372a60a963b3b2576ed932f32329ce7ddb9cb5f27a6c83040d8cd74b7a70
languageName: node
linkType: hard
"unique-filename@npm:^3.0.0": "unique-filename@npm:^3.0.0":
version: 3.0.0 version: 3.0.0
resolution: "unique-filename@npm:3.0.0" resolution: "unique-filename@npm:3.0.0"
@@ -2094,7 +2112,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"ws@npm:^8.16.0": "ws@npm:^8.18.0":
version: 8.18.0 version: 8.18.0
resolution: "ws@npm:8.18.0" resolution: "ws@npm:8.18.0"
peerDependencies: peerDependencies:
+6 -6
View File
@@ -13,15 +13,15 @@
"setup-dd": "" "setup-dd": ""
}, },
"dependencies": { "dependencies": {
"@discordeno/bot": "19.0.0-next.92bf166", "@discordeno/bot": "19.0.0",
"chalk": "^5.3.0", "chalk": "^5.3.0",
"dd-cache-proxy": "^2.1.1", "dd-cache-proxy": "^2.3.0",
"dotenv": "^16.4.5" "dotenv": "^16.4.5"
}, },
"devDependencies": { "devDependencies": {
"@swc/cli": "^0.3.12", "@swc/cli": "^0.5.0",
"@swc/core": "^1.6.3", "@swc/core": "^1.9.2",
"@types/node": "^20.14.6", "@types/node": "^22.9.0",
"typescript": "^5.5.2" "typescript": "^5.6.3"
} }
} }
+38 -24
View File
@@ -1,32 +1,46 @@
import { Intents, createBot } from '@discordeno/bot' import { type Collection, Intents, createBot } from '@discordeno/bot'
import { createProxyCache } from 'dd-cache-proxy' import { createProxyCache } from 'dd-cache-proxy'
import { configs } from './config.js' import { configs } from './config.js'
export const bot = createProxyCache( const rawBot = createBot({
createBot({ token: configs.token,
token: configs.token, intents: Intents.Guilds,
intents: Intents.Guilds, desiredProperties: {
}), interaction: {
{ id: true,
desiredProps: { type: true,
guilds: ['id', 'name'], data: true,
user: true,
token: true,
guildId: true,
}, },
cacheInMemory: { guild: {
guilds: true, id: true,
default: false, name: true,
},
user: {
username: true,
}, },
}, },
) })
// Setup desired properties // TODO: remove this type hack when dd-cache-proxy fixes support for v19
bot.transformers.desiredProperties.interaction.id = true // @ts-expect-error
bot.transformers.desiredProperties.interaction.type = true export const bot = createProxyCache(rawBot, {
bot.transformers.desiredProperties.interaction.data = true desiredProps: {
bot.transformers.desiredProperties.interaction.user = true guilds: ['id', 'name'],
bot.transformers.desiredProperties.interaction.token = true },
bot.transformers.desiredProperties.interaction.guildId = true cacheInMemory: {
guilds: true,
default: false,
},
}) as CacheBot
bot.transformers.desiredProperties.guild.id = true export type CacheBot = typeof rawBot & {
bot.transformers.desiredProperties.guild.name = true cache: {
guild: {
bot.transformers.desiredProperties.user.username = true memory: Collection<bigint, typeof rawBot.transformers.$inferredTypes.guild>
get: (guildId: bigint) => typeof rawBot.transformers.$inferredTypes.guild
}
}
}
+3 -2
View File
@@ -1,4 +1,5 @@
import { type ApplicationCommandOption, type ApplicationCommandTypes, Collection, type Interaction } from '@discordeno/bot' import { type ApplicationCommandOption, type ApplicationCommandTypes, Collection } from '@discordeno/bot'
import type { bot } from './bot.js'
export const commands = new Collection<string, Command>() export const commands = new Collection<string, Command>()
@@ -14,7 +15,7 @@ export interface Command {
type: ApplicationCommandTypes type: ApplicationCommandTypes
/** Defaults to `Guild` */ /** Defaults to `Guild` */
scope?: 'Global' | 'Guild' scope?: 'Global' | 'Guild'
execute: (interaction: Interaction) => unknown execute: (interaction: typeof bot.transformers.$inferredTypes.interaction) => unknown
subcommands?: Array<SubCommandGroup | SubCommand> subcommands?: Array<SubCommandGroup | SubCommand>
} }
+1 -1
View File
@@ -1,4 +1,4 @@
import { bot } from '../bot.js' import { bot } from '../bot.js'
import { updateGuildCommands } from '../utils/helpers.js' import { updateGuildCommands } from '../utils/helpers.js'
bot.events.guildCreate = async (guild) => await updateGuildCommands(bot, guild) bot.events.guildCreate = async (guild) => await updateGuildCommands(guild)
@@ -1,4 +1,4 @@
import { ApplicationCommandOptionTypes, type Guild, hasProperty } from '@discordeno/bot' import { ApplicationCommandOptionTypes, hasProperty } from '@discordeno/bot'
import chalk from 'chalk' import chalk from 'chalk'
import { bot } from '../bot.js' import { bot } from '../bot.js'
import { commands } from '../commands.js' import { commands } from '../commands.js'
@@ -11,7 +11,7 @@ bot.events.interactionCreate = async (interaction) => {
if (!interaction.data || !interaction.id) return if (!interaction.data || !interaction.id) return
let guildName = 'Direct Message' let guildName = 'Direct Message'
let guild = {} as Guild let guild = {} as typeof bot.transformers.$inferredTypes.guild
// Set guild, if there was an error getting the guild, then just say it was a DM. (What else are we going to do?) // Set guild, if there was an error getting the guild, then just say it was a DM. (What else are we going to do?)
if (interaction.guildId) { if (interaction.guildId) {
+1 -1
View File
@@ -12,7 +12,7 @@ bot.events.ready = async ({ shardId }) => {
activities: [ activities: [
{ {
name: 'Discordeno is the Best Lib', name: 'Discordeno is the Best Lib',
type: ActivityTypes.Game, type: ActivityTypes.Playing,
timestamps: { timestamps: {
start: Date.now(), start: Date.now(),
}, },
+5 -5
View File
@@ -1,4 +1,4 @@
import { type Bot, type CreateApplicationCommand, type Guild, hasProperty } from '@discordeno/bot' import { type CreateApplicationCommand, hasProperty } from '@discordeno/bot'
import { bot } from '../bot.js' import { bot } from '../bot.js'
import { type SubCommand, type SubCommandGroup, commands } from '../commands.js' import { type SubCommand, type SubCommandGroup, commands } from '../commands.js'
import { createLogger } from './logger.js' import { createLogger } from './logger.js'
@@ -35,7 +35,7 @@ export async function updateCommands(scope?: 'Guild' | 'Global'): Promise<void>
if (perGuildCommands.length && (scope === 'Guild' || scope === undefined)) { if (perGuildCommands.length && (scope === 'Guild' || scope === undefined)) {
await Promise.all( await Promise.all(
bot.cache.guilds.memory.map(async (guild: Guild) => { bot.cache.guild.memory.map(async (guild) => {
await bot.helpers.upsertGuildApplicationCommands(guild.id, perGuildCommands) await bot.helpers.upsertGuildApplicationCommands(guild.id, perGuildCommands)
}), }),
) )
@@ -43,7 +43,7 @@ export async function updateCommands(scope?: 'Guild' | 'Global'): Promise<void>
} }
/** Update commands for a guild */ /** Update commands for a guild */
export async function updateGuildCommands(bot: Bot, guild: Guild): Promise<void> { export async function updateGuildCommands(guild: typeof bot.transformers.$inferredTypes.guild): Promise<void> {
const perGuildCommands: MakeRequired<CreateApplicationCommand, 'name'>[] = [] const perGuildCommands: MakeRequired<CreateApplicationCommand, 'name'>[] = []
for (const command of commands.values()) { for (const command of commands.values()) {
@@ -62,8 +62,8 @@ export async function updateGuildCommands(bot: Bot, guild: Guild): Promise<void>
} }
} }
export async function getGuildFromId(guildId: bigint): Promise<Guild> { export async function getGuildFromId(guildId: bigint) {
const cached = await bot.cache.guilds.get(guildId) const cached = await bot.cache.guild.get(guildId)
if (cached) return cached if (cached) return cached
+126 -117
View File
@@ -5,54 +5,56 @@ __metadata:
version: 8 version: 8
cacheKey: 10 cacheKey: 10
"@discordeno/bot@npm:19.0.0-next.92bf166": "@discordeno/bot@npm:19.0.0":
version: 19.0.0-next.92bf166 version: 19.0.0
resolution: "@discordeno/bot@npm:19.0.0-next.92bf166" resolution: "@discordeno/bot@npm:19.0.0"
dependencies: dependencies:
"@discordeno/gateway": "npm:19.0.0-next.92bf166" "@discordeno/gateway": "npm:19.0.0"
"@discordeno/rest": "npm:19.0.0-next.92bf166" "@discordeno/rest": "npm:19.0.0"
"@discordeno/types": "npm:19.0.0-next.92bf166" "@discordeno/types": "npm:19.0.0"
"@discordeno/utils": "npm:19.0.0-next.92bf166" "@discordeno/utils": "npm:19.0.0"
checksum: 3020e74c774eae34307d434ad38f983e90839dc5fad7578f3cda4fba6c1efb7a22c4f4cdcfff58c54b62cc14976ad974256955d5117e490f78ec9e835e02c682 checksum: 86ac4cd61761c1b3c3fa82db08742dcdba18ffb1b6042455c8a5e8cdd02231543c3c2d43dfb29084d44034cafebdc6ab51969c5930281ab2be83d5b159b69726
languageName: node languageName: node
linkType: hard linkType: hard
"@discordeno/gateway@npm:19.0.0-next.92bf166": "@discordeno/gateway@npm:19.0.0":
version: 19.0.0-next.92bf166 version: 19.0.0
resolution: "@discordeno/gateway@npm:19.0.0-next.92bf166" resolution: "@discordeno/gateway@npm:19.0.0"
dependencies: dependencies:
"@discordeno/types": "npm:19.0.0-next.92bf166" "@discordeno/types": "npm:19.0.0"
"@discordeno/utils": "npm:19.0.0-next.92bf166" "@discordeno/utils": "npm:19.0.0"
ws: "npm:^8.16.0" fzstd: "npm:^0.1.1"
checksum: 6a11ca7a4cb98f48726664d0baa27d04e26342bf94d6e439494e462636af20d17b567e9d3e2e478465aabcecb98a21e54b860b39b9f1022eef922e76d947ddcb ws: "npm:^8.18.0"
dependenciesMeta:
fzstd:
optional: true
checksum: 241ec9981bf47ff894990889477fbc1ce91361648534189361e9dca4d927aba15c941604da29ba135cb20871fac7e82e5cc1eed1df6ef3d86bbcdfdca3448649
languageName: node languageName: node
linkType: hard linkType: hard
"@discordeno/rest@npm:19.0.0-next.92bf166": "@discordeno/rest@npm:19.0.0":
version: 19.0.0-next.92bf166 version: 19.0.0
resolution: "@discordeno/rest@npm:19.0.0-next.92bf166" resolution: "@discordeno/rest@npm:19.0.0"
dependencies: dependencies:
"@discordeno/types": "npm:19.0.0-next.92bf166" "@discordeno/types": "npm:19.0.0"
"@discordeno/utils": "npm:19.0.0-next.92bf166" "@discordeno/utils": "npm:19.0.0"
dotenv: "npm:^16.4.5" checksum: e1ce6c092566e58c5d407a5fee7c6c38f988251abcbaaf14beaa084691b4c52dc4f6c54f46974735090fafe174b1914374edd074bffd441e11d76851575a136f
checksum: 45f6ba4791003b77c883e991ad348597197d70e25e335b8628a03bd2effa8e2047a2f987f4c0b6ee8b17c01f77055d7a1ddc9f5350eb8f1c8ff8c8d39f91d787
languageName: node languageName: node
linkType: hard linkType: hard
"@discordeno/types@npm:19.0.0-next.92bf166": "@discordeno/types@npm:19.0.0":
version: 19.0.0-next.92bf166 version: 19.0.0
resolution: "@discordeno/types@npm:19.0.0-next.92bf166" resolution: "@discordeno/types@npm:19.0.0"
checksum: f88e78a18e51c179b94ef14e8bcdd6b5e6c5f25bdd6c4308bec121e5e59533612b36ed0e7a447daedc009053e1e30c6c8e13b2276bb1ce7e2f840ff58473a2ef checksum: aaf832d6510b7aa0ead75bd5c1d1990f3a77fa980d40122d6d092abc571280aed6864b10fdda705d70bd7ba73961f4b3a0ee28c6b7cabb09595574f65fcfd61c
languageName: node languageName: node
linkType: hard linkType: hard
"@discordeno/utils@npm:19.0.0-next.92bf166": "@discordeno/utils@npm:19.0.0":
version: 19.0.0-next.92bf166 version: 19.0.0
resolution: "@discordeno/utils@npm:19.0.0-next.92bf166" resolution: "@discordeno/utils@npm:19.0.0"
dependencies: dependencies:
"@discordeno/types": "npm:19.0.0-next.92bf166" "@discordeno/types": "npm:19.0.0"
tweetnacl: "npm:^1.0.3" checksum: b2d430099672cfb8b68d6a9bd12803cd69cb909dc1f368d8305a4bb1067499babff05997a29599b51029d0add435bea4a03929140abf77dd83e1741baaa37855
checksum: 7962a057ba5908936e4224df70b9ceaffcb8ec7ad220a999b36fc0601365b380bb0de01b6adfa4c36250247e3d15e22215fc63bbe3634b932434411c5f4ca13d
languageName: node languageName: node
linkType: hard linkType: hard
@@ -149,9 +151,9 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/cli@npm:^0.3.12": "@swc/cli@npm:^0.5.0":
version: 0.3.12 version: 0.5.0
resolution: "@swc/cli@npm:0.3.12" resolution: "@swc/cli@npm:0.5.0"
dependencies: dependencies:
"@mole-inc/bin-wrapper": "npm:^8.0.1" "@mole-inc/bin-wrapper": "npm:^8.0.1"
"@swc/counter": "npm:^0.1.3" "@swc/counter": "npm:^0.1.3"
@@ -172,96 +174,96 @@ __metadata:
spack: bin/spack.js spack: bin/spack.js
swc: bin/swc.js swc: bin/swc.js
swcx: bin/swcx.js swcx: bin/swcx.js
checksum: fee260434fad8eed0328f4db17f42ce0864b93b90fcb02f3f0eb3aad994b5a6ae4bfdfb6d2329377e0cd8d07adc61cca42e290bf0005c1ab4d004d4a0b152db4 checksum: 033b682f1c25c8fae731414d2a463a0e455452bf9349c025cd88ea63ee1e5a589032eb206063fd925daf12065c9f1e5b4680cef50cc24674681c4d2583b7dca0
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-darwin-arm64@npm:1.6.3": "@swc/core-darwin-arm64@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-darwin-arm64@npm:1.6.3" resolution: "@swc/core-darwin-arm64@npm:1.9.2"
conditions: os=darwin & cpu=arm64 conditions: os=darwin & cpu=arm64
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-darwin-x64@npm:1.6.3": "@swc/core-darwin-x64@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-darwin-x64@npm:1.6.3" resolution: "@swc/core-darwin-x64@npm:1.9.2"
conditions: os=darwin & cpu=x64 conditions: os=darwin & cpu=x64
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-linux-arm-gnueabihf@npm:1.6.3": "@swc/core-linux-arm-gnueabihf@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-linux-arm-gnueabihf@npm:1.6.3" resolution: "@swc/core-linux-arm-gnueabihf@npm:1.9.2"
conditions: os=linux & cpu=arm conditions: os=linux & cpu=arm
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-linux-arm64-gnu@npm:1.6.3": "@swc/core-linux-arm64-gnu@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-linux-arm64-gnu@npm:1.6.3" resolution: "@swc/core-linux-arm64-gnu@npm:1.9.2"
conditions: os=linux & cpu=arm64 & libc=glibc conditions: os=linux & cpu=arm64 & libc=glibc
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-linux-arm64-musl@npm:1.6.3": "@swc/core-linux-arm64-musl@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-linux-arm64-musl@npm:1.6.3" resolution: "@swc/core-linux-arm64-musl@npm:1.9.2"
conditions: os=linux & cpu=arm64 & libc=musl conditions: os=linux & cpu=arm64 & libc=musl
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-linux-x64-gnu@npm:1.6.3": "@swc/core-linux-x64-gnu@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-linux-x64-gnu@npm:1.6.3" resolution: "@swc/core-linux-x64-gnu@npm:1.9.2"
conditions: os=linux & cpu=x64 & libc=glibc conditions: os=linux & cpu=x64 & libc=glibc
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-linux-x64-musl@npm:1.6.3": "@swc/core-linux-x64-musl@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-linux-x64-musl@npm:1.6.3" resolution: "@swc/core-linux-x64-musl@npm:1.9.2"
conditions: os=linux & cpu=x64 & libc=musl conditions: os=linux & cpu=x64 & libc=musl
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-win32-arm64-msvc@npm:1.6.3": "@swc/core-win32-arm64-msvc@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-win32-arm64-msvc@npm:1.6.3" resolution: "@swc/core-win32-arm64-msvc@npm:1.9.2"
conditions: os=win32 & cpu=arm64 conditions: os=win32 & cpu=arm64
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-win32-ia32-msvc@npm:1.6.3": "@swc/core-win32-ia32-msvc@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-win32-ia32-msvc@npm:1.6.3" resolution: "@swc/core-win32-ia32-msvc@npm:1.9.2"
conditions: os=win32 & cpu=ia32 conditions: os=win32 & cpu=ia32
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-win32-x64-msvc@npm:1.6.3": "@swc/core-win32-x64-msvc@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-win32-x64-msvc@npm:1.6.3" resolution: "@swc/core-win32-x64-msvc@npm:1.9.2"
conditions: os=win32 & cpu=x64 conditions: os=win32 & cpu=x64
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core@npm:^1.6.3": "@swc/core@npm:^1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core@npm:1.6.3" resolution: "@swc/core@npm:1.9.2"
dependencies: dependencies:
"@swc/core-darwin-arm64": "npm:1.6.3" "@swc/core-darwin-arm64": "npm:1.9.2"
"@swc/core-darwin-x64": "npm:1.6.3" "@swc/core-darwin-x64": "npm:1.9.2"
"@swc/core-linux-arm-gnueabihf": "npm:1.6.3" "@swc/core-linux-arm-gnueabihf": "npm:1.9.2"
"@swc/core-linux-arm64-gnu": "npm:1.6.3" "@swc/core-linux-arm64-gnu": "npm:1.9.2"
"@swc/core-linux-arm64-musl": "npm:1.6.3" "@swc/core-linux-arm64-musl": "npm:1.9.2"
"@swc/core-linux-x64-gnu": "npm:1.6.3" "@swc/core-linux-x64-gnu": "npm:1.9.2"
"@swc/core-linux-x64-musl": "npm:1.6.3" "@swc/core-linux-x64-musl": "npm:1.9.2"
"@swc/core-win32-arm64-msvc": "npm:1.6.3" "@swc/core-win32-arm64-msvc": "npm:1.9.2"
"@swc/core-win32-ia32-msvc": "npm:1.6.3" "@swc/core-win32-ia32-msvc": "npm:1.9.2"
"@swc/core-win32-x64-msvc": "npm:1.6.3" "@swc/core-win32-x64-msvc": "npm:1.9.2"
"@swc/counter": "npm:^0.1.3" "@swc/counter": "npm:^0.1.3"
"@swc/types": "npm:^0.1.8" "@swc/types": "npm:^0.1.15"
peerDependencies: peerDependencies:
"@swc/helpers": "*" "@swc/helpers": "*"
dependenciesMeta: dependenciesMeta:
@@ -288,7 +290,7 @@ __metadata:
peerDependenciesMeta: peerDependenciesMeta:
"@swc/helpers": "@swc/helpers":
optional: true optional: true
checksum: b4c84a083ecabb0280ba53dffa65a5a575321de94081ad52bd12027fe3b5c8957978f2211b6036e2e28d904dd046fca238106c2106b32d02b752808a51193d35 checksum: 6793f2014a016f90b1c41a695f6d3a14d574e129e78f651fe3d6dbacbc6d0836ab7a7eb445d873a302b060b25ae34c4e09d0f94574a71da47c6424c5fa58aa10
languageName: node languageName: node
linkType: hard linkType: hard
@@ -299,12 +301,12 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/types@npm:^0.1.8": "@swc/types@npm:^0.1.15":
version: 0.1.8 version: 0.1.15
resolution: "@swc/types@npm:0.1.8" resolution: "@swc/types@npm:0.1.15"
dependencies: dependencies:
"@swc/counter": "npm:^0.1.3" "@swc/counter": "npm:^0.1.3"
checksum: 2d1cda35116e03714137c1c37f4493efe0e26e88285ecc9dcdf6256a77984e367ea7b5f31d650f110fdcfd6ac53dff3ec77f841787ca328d2efa7b07ef1ac318 checksum: d8bf063aeebac51290d1edf0cec52e2e5b5afced0dc6933510a86947e10f0f77976bc14c3efb5e8f265a9cbdeb0929e00e44b2f82c6d0f273997c5029417b769
languageName: node languageName: node
linkType: hard linkType: hard
@@ -361,12 +363,12 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@types/node@npm:^20.14.6": "@types/node@npm:^22.9.0":
version: 20.14.6 version: 22.9.0
resolution: "@types/node@npm:20.14.6" resolution: "@types/node@npm:22.9.0"
dependencies: dependencies:
undici-types: "npm:~5.26.4" undici-types: "npm:~6.19.8"
checksum: 1dcfeeb03ce3c3a1d8a537fefee7cd0cffb78f89e9535b74ee12940559566b57c39dad20d1b165b60b5727408dd44e1a52e5c01cf02d0a99d93ef3da8062c86e checksum: a7df3426891868b0f5fb03e46aeddd8446178233521c624a44531c92a040cf08a82d8235f7e1e02af731fd16984665d4d71f3418caf9c2788313b10f040d615d
languageName: node languageName: node
linkType: hard linkType: hard
@@ -628,23 +630,23 @@ __metadata:
version: 0.0.0-use.local version: 0.0.0-use.local
resolution: "dd-beginner-bot@workspace:." resolution: "dd-beginner-bot@workspace:."
dependencies: dependencies:
"@discordeno/bot": "npm:19.0.0-next.92bf166" "@discordeno/bot": "npm:19.0.0"
"@swc/cli": "npm:^0.3.12" "@swc/cli": "npm:^0.5.0"
"@swc/core": "npm:^1.6.3" "@swc/core": "npm:^1.9.2"
"@types/node": "npm:^20.14.6" "@types/node": "npm:^22.9.0"
chalk: "npm:^5.3.0" chalk: "npm:^5.3.0"
dd-cache-proxy: "npm:^2.1.1" dd-cache-proxy: "npm:^2.3.0"
dotenv: "npm:^16.4.5" dotenv: "npm:^16.4.5"
typescript: "npm:^5.5.2" typescript: "npm:^5.6.3"
languageName: unknown languageName: unknown
linkType: soft linkType: soft
"dd-cache-proxy@npm:^2.1.1": "dd-cache-proxy@npm:^2.3.0":
version: 2.1.1 version: 2.3.0
resolution: "dd-cache-proxy@npm:2.1.1" resolution: "dd-cache-proxy@npm:2.3.0"
peerDependencies: peerDependencies:
"@discordeno/bot": 19.0.0-next.d69e537 "@discordeno/bot": 19.0.0-next.b85c6d5
checksum: 082234277fd0dc91477b0ac4a938aea40b8d3ffa60e7e458ce570b2f4c919671ecd5b601f7ff6c6157a5e4e5eaa3786e6a1884cccb020a938cb76e4e300f0f72 checksum: eda7d43717567b7836208c9690bbc0a547179ff7319daf5ccc08c83bc44d481854bcb474075021646ddc8560015d8b0d5e5c66f72ace67f858484b805a40f5a1
languageName: node languageName: node
linkType: hard linkType: hard
@@ -907,6 +909,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"fzstd@npm:^0.1.1":
version: 0.1.1
resolution: "fzstd@npm:0.1.1"
checksum: 455b968aeb764f06d9c39a5c8b45eefd645f7ee9129896e890eafb8ab367482f8495de12907021a32f6544494305a42a2056c30c63efac06181e6efcdab3fe78
languageName: node
linkType: hard
"get-stream@npm:^3.0.0": "get-stream@npm:^3.0.0":
version: 3.0.0 version: 3.0.0
resolution: "get-stream@npm:3.0.0" resolution: "get-stream@npm:3.0.0"
@@ -1982,30 +1991,23 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"tweetnacl@npm:^1.0.3": "typescript@npm:^5.6.3":
version: 1.0.3 version: 5.6.3
resolution: "tweetnacl@npm:1.0.3" resolution: "typescript@npm:5.6.3"
checksum: ca122c2f86631f3c0f6d28efb44af2a301d4a557a62a3e2460286b08e97567b258c2212e4ad1cfa22bd6a57edcdc54ba76ebe946847450ab0999e6d48ccae332
languageName: node
linkType: hard
"typescript@npm:^5.5.2":
version: 5.5.2
resolution: "typescript@npm:5.5.2"
bin: bin:
tsc: bin/tsc tsc: bin/tsc
tsserver: bin/tsserver tsserver: bin/tsserver
checksum: 9118b20f248e76b0dbff8737fef65dfa89d02668d4e633d2c5ceac99033a0ca5e8a1c1a53bc94da68e8f67677a88f318663dde859c9e9a09c1e116415daec2ba checksum: c328e418e124b500908781d9f7b9b93cf08b66bf5936d94332b463822eea2f4e62973bfb3b8a745fdc038785cb66cf59d1092bac3ec2ac6a3e5854687f7833f1
languageName: node languageName: node
linkType: hard linkType: hard
"typescript@patch:typescript@npm%3A^5.5.2#optional!builtin<compat/typescript>": "typescript@patch:typescript@npm%3A^5.6.3#optional!builtin<compat/typescript>":
version: 5.5.2 version: 5.6.3
resolution: "typescript@patch:typescript@npm%3A5.5.2#optional!builtin<compat/typescript>::version=5.5.2&hash=e012d7" resolution: "typescript@patch:typescript@npm%3A5.6.3#optional!builtin<compat/typescript>::version=5.6.3&hash=e012d7"
bin: bin:
tsc: bin/tsc tsc: bin/tsc
tsserver: bin/tsserver tsserver: bin/tsserver
checksum: 28b3de2ddaf63a7620e7ddbe5d377af71ce93ecc558c41bf0e3d88661d8e6e7aa6c7739164fef98055f69819e41faca49252938ef3633a3dff2734cca6a9042e checksum: dc4bec403cd33a204b655b1152a096a08e7bad2c931cb59ef8ff26b6f2aa541bf98f09fc157958a60c921b1983a8dde9a85b692f9de60fa8f574fd131e3ae4dd
languageName: node languageName: node
linkType: hard linkType: hard
@@ -2016,6 +2018,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"undici-types@npm:~6.19.8":
version: 6.19.8
resolution: "undici-types@npm:6.19.8"
checksum: cf0b48ed4fc99baf56584afa91aaffa5010c268b8842f62e02f752df209e3dea138b372a60a963b3b2576ed932f32329ce7ddb9cb5f27a6c83040d8cd74b7a70
languageName: node
linkType: hard
"unique-filename@npm:^3.0.0": "unique-filename@npm:^3.0.0":
version: 3.0.0 version: 3.0.0
resolution: "unique-filename@npm:3.0.0" resolution: "unique-filename@npm:3.0.0"
@@ -2103,7 +2112,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"ws@npm:^8.16.0": "ws@npm:^8.18.0":
version: 8.18.0 version: 8.18.0
resolution: "ws@npm:8.18.0" resolution: "ws@npm:8.18.0"
peerDependencies: peerDependencies:
+1
View File
@@ -74,6 +74,7 @@ The preset value of `EVENT_HANDLER_HOST`, `REST_HOST`, and `GATEWAY_HOST` all us
#### Setup process #### Setup process
- Install the dependencies with yarn - Install the dependencies with yarn
- Run the Discordeno desired properties CLI with `yarn postinstall`
- Build the code with `yarn build` - Build the code with `yarn build`
You can start different parts of your bot in the following order. You can start different parts of your bot in the following order.
+7 -7
View File
@@ -19,18 +19,18 @@
"setup-dd": "" "setup-dd": ""
}, },
"dependencies": { "dependencies": {
"@discordeno/bot": "19.0.0-next.92bf166", "@discordeno/bot": "19.0.0",
"@fastify/multipart": "^8.3.0", "@fastify/multipart": "^9.0.1",
"@influxdata/influxdb-client": "^1.33.2", "@influxdata/influxdb-client": "^1.33.2",
"amqplib": "^0.10.4", "amqplib": "^0.10.4",
"chalk": "^5.3.0", "chalk": "^5.3.0",
"fastify": "^4.28.0" "fastify": "^5.1.0"
}, },
"devDependencies": { "devDependencies": {
"@swc/cli": "^0.3.12", "@swc/cli": "^0.5.0",
"@swc/core": "^1.6.3", "@swc/core": "^1.9.2",
"@types/amqplib": "^0.10.5", "@types/amqplib": "^0.10.5",
"@types/node": "^20.14.6", "@types/node": "^22.9.0",
"typescript": "^5.5.2" "typescript": "^5.6.3"
} }
} }
+35 -39
View File
@@ -1,50 +1,46 @@
import { type Bot, Collection, LogDepth, createBot, type logger } from '@discordeno/bot' import { Collection, LogDepth, createBot, type logger } from '@discordeno/bot'
import { DISCORD_TOKEN, GATEWAY_AUTHORIZATION, GATEWAY_INTENTS, GATEWAY_URL, REST_AUTHORIZATION, REST_URL } from '../config.js' import { DISCORD_TOKEN, GATEWAY_AUTHORIZATION, GATEWAY_INTENTS, GATEWAY_URL, REST_AUTHORIZATION, REST_URL } from '../config.js'
import type { ManagerGetShardInfoFromGuildId, ShardInfo, WorkerPresencesUpdate, WorkerShardPayload } from '../gateway/worker/types.js' import type { ManagerGetShardInfoFromGuildId, ShardInfo, WorkerPresencesUpdate, WorkerShardPayload } from '../gateway/worker/types.js'
import type { Command } from './commands.js' import type { Command } from './commands.js'
export const bot = createCustomBot( const rawBot = createBot({
createBot({ token: DISCORD_TOKEN,
token: DISCORD_TOKEN, intents: GATEWAY_INTENTS,
intents: GATEWAY_INTENTS, // TEMPLATE-SETUP: Add/Remove the desired properties that you don't need
rest: { desiredProperties: {
token: DISCORD_TOKEN, user: {
proxy: { id: true,
baseUrl: REST_URL, username: true,
authorization: REST_AUTHORIZATION,
},
}, },
}), interaction: {
) id: true,
data: true,
type: true,
user: true,
token: true,
guildId: true,
},
},
rest: {
token: DISCORD_TOKEN,
proxy: {
baseUrl: REST_URL,
authorization: REST_AUTHORIZATION,
},
},
})
export const bot = rawBot as CustomBot
// TEMPLATE-SETUP: If you want/need to add any custom properties on the Bot type, you can do it in these lines below and the `CustomBot` type below. Make sure to do it in both or else you will get an error by TypeScript
// We need to set the log depth for the default discordeno logger or else only the first param will be logged
;(bot.logger as typeof logger).setDepth(LogDepth.Full)
bot.commands = new Collection()
overrideGatewayImplementations(bot) overrideGatewayImplementations(bot)
// TEMPLATE-SETUP: Add/Remove the desired properties that you don't need export type CustomBot = typeof rawBot & {
const props = bot.transformers.desiredProperties
props.interaction.id = true
props.interaction.data = true
props.interaction.type = true
props.interaction.user = true
props.interaction.token = true
props.interaction.guildId = true
props.user.id = true
props.user.username = true
// TEMPLATE-SETUP: If you want/need to add any custom properties on the Bot type, you can do it in this function and the `CustomBot` type below. Make sure to do it in both or else you will get an error by TypeScript
function createCustomBot<TBot extends Bot = Bot>(rawBot: TBot): CustomBot<TBot> {
const bot = rawBot as CustomBot<TBot>
// We need to set the log depth for the default discordeno logger or else only the first param will be logged
;(bot.logger as typeof logger).setDepth(LogDepth.Full)
bot.commands = new Collection()
return bot
}
export type CustomBot<TBot extends Bot = Bot> = TBot & {
commands: Collection<string, Command> commands: Collection<string, Command>
} }
+22 -26
View File
@@ -1,13 +1,9 @@
import type { import type {
ApplicationCommandOptionTypes, ApplicationCommandOptionTypes,
Attachment, Camelize,
CamelizedDiscordApplicationCommandOption,
ChannelTypes,
CreateApplicationCommand, CreateApplicationCommand,
Interaction, DiscordApplicationCommandOption,
Member, ParsedInteractionOption,
Role,
User,
} from '@discordeno/bot' } from '@discordeno/bot'
import { bot } from './bot.js' import { bot } from './bot.js'
@@ -25,33 +21,33 @@ export type Command<TOptions extends CommandOptions = CommandOptions> = CreateAp
*/ */
devOnly?: boolean devOnly?: boolean
/** Function to run when the interaction is executed */ /** Function to run when the interaction is executed */
run: (interaction: Interaction, options: GetCommandOptions<TOptions>) => unknown run: (interaction: typeof bot.transformers.$inferredTypes.interaction, options: GetCommandOptions<TOptions>) => unknown
/** Function to run when an autocomplete interaction is fired */ /** Function to run when an autocomplete interaction is fired */
autoComplete?: (interaction: Interaction, options: GetCommandOptions<TOptions>) => unknown autoComplete?: (interaction: typeof bot.transformers.$inferredTypes.interaction, options: GetCommandOptions<TOptions>) => unknown
} }
export type GetCommandOptions<T extends CommandOptions> = T extends CommandOptions export type GetCommandOptions<T extends CommandOptions> = T extends CommandOptions
? { [Prop in keyof BuildOptions<T> as Prop]: BuildOptions<T>[Prop] } ? { [Prop in keyof BuildOptions<T> as Prop]: BuildOptions<T>[Prop] }
: never : never
export type CommandOption = CamelizedDiscordApplicationCommandOption export type CommandOption = Camelize<DiscordApplicationCommandOption>
export type CommandOptions = CommandOption[] export type CommandOptions = CommandOption[]
// Option parsing // Option parsing
interface UserResolved { type ResolvedValues = ParsedInteractionOption[string]
user: User
member: Member | undefined
}
interface ChannelResolved { // Using omit + exclude is a slight trick to avoid a type error on Pick
id: bigint export type InteractionResolvedChannel = Omit<
name: string typeof bot.transformers.$inferredTypes.channel,
type: ChannelTypes Exclude<keyof typeof bot.transformers.$inferredTypes.channel, 'id' | 'name' | 'type' | 'permissions' | 'threadMetadata' | 'parentId'>
permissions: bigint >
} export type InteractionResolvedMember = Omit<typeof bot.transformers.$inferredTypes.member, 'user' | 'deaf' | 'mute'>
type ResolvedValues = number | boolean | UserResolved | Role | ChannelResolved | Attachment export interface InteractionResolvedUser {
user: typeof bot.transformers.$inferredTypes.user
member: InteractionResolvedMember
}
/** /**
* From here SubCommandGroup and SubCommand are missing, this is wanted. * From here SubCommandGroup and SubCommand are missing, this is wanted.
@@ -62,12 +58,12 @@ interface TypeToResolvedMap {
[ApplicationCommandOptionTypes.String]: string [ApplicationCommandOptionTypes.String]: string
[ApplicationCommandOptionTypes.Integer]: number [ApplicationCommandOptionTypes.Integer]: number
[ApplicationCommandOptionTypes.Boolean]: boolean [ApplicationCommandOptionTypes.Boolean]: boolean
[ApplicationCommandOptionTypes.User]: UserResolved [ApplicationCommandOptionTypes.User]: InteractionResolvedUser
[ApplicationCommandOptionTypes.Channel]: ChannelResolved [ApplicationCommandOptionTypes.Channel]: InteractionResolvedChannel
[ApplicationCommandOptionTypes.Role]: Role [ApplicationCommandOptionTypes.Role]: typeof bot.transformers.$inferredTypes.role
[ApplicationCommandOptionTypes.Mentionable]: Role | UserResolved [ApplicationCommandOptionTypes.Mentionable]: typeof bot.transformers.$inferredTypes.role | InteractionResolvedUser
[ApplicationCommandOptionTypes.Number]: number [ApplicationCommandOptionTypes.Number]: number
[ApplicationCommandOptionTypes.Attachment]: Attachment [ApplicationCommandOptionTypes.Attachment]: typeof bot.transformers.$inferredTypes.attachment
} }
type ConvertTypeToResolved<T extends ApplicationCommandOptionTypes> = T extends keyof TypeToResolvedMap ? TypeToResolvedMap[T] : ResolvedValues type ConvertTypeToResolved<T extends ApplicationCommandOptionTypes> = T extends keyof TypeToResolvedMap ? TypeToResolvedMap[T] : ResolvedValues
@@ -1,4 +1,4 @@
import { type Interaction, InteractionTypes, LogLevels, commandOptionsParser, type logger } from '@discordeno/bot' import { InteractionTypes, LogLevels, commandOptionsParser, type logger } from '@discordeno/bot'
import chalk from 'chalk' import chalk from 'chalk'
import { bot } from '../../bot.js' import { bot } from '../../bot.js'
@@ -19,6 +19,7 @@ bot.events.interactionCreate = async (interaction) => {
logCommand(interaction, 'Trigger', interaction.data.name) logCommand(interaction, 'Trigger', interaction.data.name)
// @ts-expect-error commandOptionsParser is currently bugged
const options = commandOptionsParser(interaction) const options = commandOptionsParser(interaction)
try { try {
@@ -36,7 +37,7 @@ bot.events.interactionCreate = async (interaction) => {
} }
function logCommand( function logCommand(
interaction: Interaction, interaction: typeof bot.transformers.$inferredTypes.interaction,
type: 'Failure' | 'Success' | 'Trigger' | 'Missing', type: 'Failure' | 'Success' | 'Trigger' | 'Missing',
commandName: string, commandName: string,
logLevel: LogLevels = LogLevels.Info, logLevel: LogLevels = LogLevels.Info,
@@ -96,6 +96,7 @@ function createShard(shardId: number): DiscordenoShard {
totalShards: workerData.connectionData.totalShards, totalShards: workerData.connectionData.totalShards,
url: workerData.connectionData.url, url: workerData.connectionData.url,
version: workerData.connectionData.version, version: workerData.connectionData.version,
transportCompression: null,
}, },
}) })
+274 -253
View File
@@ -16,99 +16,101 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@discordeno/bot@npm:19.0.0-next.92bf166": "@discordeno/bot@npm:19.0.0":
version: 19.0.0-next.92bf166 version: 19.0.0
resolution: "@discordeno/bot@npm:19.0.0-next.92bf166" resolution: "@discordeno/bot@npm:19.0.0"
dependencies: dependencies:
"@discordeno/gateway": "npm:19.0.0-next.92bf166" "@discordeno/gateway": "npm:19.0.0"
"@discordeno/rest": "npm:19.0.0-next.92bf166" "@discordeno/rest": "npm:19.0.0"
"@discordeno/types": "npm:19.0.0-next.92bf166" "@discordeno/types": "npm:19.0.0"
"@discordeno/utils": "npm:19.0.0-next.92bf166" "@discordeno/utils": "npm:19.0.0"
checksum: 3020e74c774eae34307d434ad38f983e90839dc5fad7578f3cda4fba6c1efb7a22c4f4cdcfff58c54b62cc14976ad974256955d5117e490f78ec9e835e02c682 checksum: 86ac4cd61761c1b3c3fa82db08742dcdba18ffb1b6042455c8a5e8cdd02231543c3c2d43dfb29084d44034cafebdc6ab51969c5930281ab2be83d5b159b69726
languageName: node languageName: node
linkType: hard linkType: hard
"@discordeno/gateway@npm:19.0.0-next.92bf166": "@discordeno/gateway@npm:19.0.0":
version: 19.0.0-next.92bf166 version: 19.0.0
resolution: "@discordeno/gateway@npm:19.0.0-next.92bf166" resolution: "@discordeno/gateway@npm:19.0.0"
dependencies: dependencies:
"@discordeno/types": "npm:19.0.0-next.92bf166" "@discordeno/types": "npm:19.0.0"
"@discordeno/utils": "npm:19.0.0-next.92bf166" "@discordeno/utils": "npm:19.0.0"
ws: "npm:^8.16.0" fzstd: "npm:^0.1.1"
checksum: 6a11ca7a4cb98f48726664d0baa27d04e26342bf94d6e439494e462636af20d17b567e9d3e2e478465aabcecb98a21e54b860b39b9f1022eef922e76d947ddcb ws: "npm:^8.18.0"
dependenciesMeta:
fzstd:
optional: true
checksum: 241ec9981bf47ff894990889477fbc1ce91361648534189361e9dca4d927aba15c941604da29ba135cb20871fac7e82e5cc1eed1df6ef3d86bbcdfdca3448649
languageName: node languageName: node
linkType: hard linkType: hard
"@discordeno/rest@npm:19.0.0-next.92bf166": "@discordeno/rest@npm:19.0.0":
version: 19.0.0-next.92bf166 version: 19.0.0
resolution: "@discordeno/rest@npm:19.0.0-next.92bf166" resolution: "@discordeno/rest@npm:19.0.0"
dependencies: dependencies:
"@discordeno/types": "npm:19.0.0-next.92bf166" "@discordeno/types": "npm:19.0.0"
"@discordeno/utils": "npm:19.0.0-next.92bf166" "@discordeno/utils": "npm:19.0.0"
dotenv: "npm:^16.4.5" checksum: e1ce6c092566e58c5d407a5fee7c6c38f988251abcbaaf14beaa084691b4c52dc4f6c54f46974735090fafe174b1914374edd074bffd441e11d76851575a136f
checksum: 45f6ba4791003b77c883e991ad348597197d70e25e335b8628a03bd2effa8e2047a2f987f4c0b6ee8b17c01f77055d7a1ddc9f5350eb8f1c8ff8c8d39f91d787
languageName: node languageName: node
linkType: hard linkType: hard
"@discordeno/types@npm:19.0.0-next.92bf166": "@discordeno/types@npm:19.0.0":
version: 19.0.0-next.92bf166 version: 19.0.0
resolution: "@discordeno/types@npm:19.0.0-next.92bf166" resolution: "@discordeno/types@npm:19.0.0"
checksum: f88e78a18e51c179b94ef14e8bcdd6b5e6c5f25bdd6c4308bec121e5e59533612b36ed0e7a447daedc009053e1e30c6c8e13b2276bb1ce7e2f840ff58473a2ef checksum: aaf832d6510b7aa0ead75bd5c1d1990f3a77fa980d40122d6d092abc571280aed6864b10fdda705d70bd7ba73961f4b3a0ee28c6b7cabb09595574f65fcfd61c
languageName: node languageName: node
linkType: hard linkType: hard
"@discordeno/utils@npm:19.0.0-next.92bf166": "@discordeno/utils@npm:19.0.0":
version: 19.0.0-next.92bf166 version: 19.0.0
resolution: "@discordeno/utils@npm:19.0.0-next.92bf166" resolution: "@discordeno/utils@npm:19.0.0"
dependencies: dependencies:
"@discordeno/types": "npm:19.0.0-next.92bf166" "@discordeno/types": "npm:19.0.0"
tweetnacl: "npm:^1.0.3" checksum: b2d430099672cfb8b68d6a9bd12803cd69cb909dc1f368d8305a4bb1067499babff05997a29599b51029d0add435bea4a03929140abf77dd83e1741baaa37855
checksum: 7962a057ba5908936e4224df70b9ceaffcb8ec7ad220a999b36fc0601365b380bb0de01b6adfa4c36250247e3d15e22215fc63bbe3634b932434411c5f4ca13d
languageName: node languageName: node
linkType: hard linkType: hard
"@fastify/ajv-compiler@npm:^3.5.0": "@fastify/ajv-compiler@npm:^4.0.0":
version: 3.5.0 version: 4.0.1
resolution: "@fastify/ajv-compiler@npm:3.5.0" resolution: "@fastify/ajv-compiler@npm:4.0.1"
dependencies: dependencies:
ajv: "npm:^8.11.0" ajv: "npm:^8.12.0"
ajv-formats: "npm:^2.1.1" ajv-formats: "npm:^3.0.1"
fast-uri: "npm:^2.0.0" fast-uri: "npm:^3.0.0"
checksum: c46c4680bf583e37b97ffc85b69070712c9c47e18ddf89b9fb93dbc0b6ba3c6496cf624aabe9aac25dafc4a404b738ab0fedcff66503df0ce18d9dcad9e44b26 checksum: ba1348cb5c4bd9c921a53e509ac6acb8696d542198f3bc7674a15b9b6b1af158b2859e738d754eb2929c4059bfa354a743f71c32aa8de6df42531a32647eeee0
languageName: node languageName: node
linkType: hard linkType: hard
"@fastify/busboy@npm:^2.1.0": "@fastify/busboy@npm:^3.0.0":
version: 2.1.1 version: 3.0.0
resolution: "@fastify/busboy@npm:2.1.1" resolution: "@fastify/busboy@npm:3.0.0"
checksum: 2bb8a7eca8289ed14c9eb15239bc1019797454624e769b39a0b90ed204d032403adc0f8ed0d2aef8a18c772205fa7808cf5a1b91f21c7bfc7b6032150b1062c5 checksum: 238ce60bffecdefc55524d2b0826fe7a225635a2e0f3af832fe48801d96f9f521cb11bbd0ed3391b017c1f2580501845ee42f153fa6204b4c758214128a67ee7
languageName: node languageName: node
linkType: hard linkType: hard
"@fastify/deepmerge@npm:^1.0.0": "@fastify/deepmerge@npm:^2.0.0":
version: 1.3.0 version: 2.0.0
resolution: "@fastify/deepmerge@npm:1.3.0" resolution: "@fastify/deepmerge@npm:2.0.0"
checksum: 6ddfc230ed46bfb158dbf83c2cc7f6119c9c1afb96d885cf5d95ac17b56126d04eef83ddb1ee7a1b044e65a128c76ebf8b391a26490b19f5812fa0d2d2a3a675 checksum: 9c3d1a02d83d9872477ef9e9d7c3c13ba138597ca01808eb233bae12923b2f5428ae6adffd4b9ed6d75e5cb86f8924e1d9a06a975132735bf9a58289d63dd146
languageName: node languageName: node
linkType: hard linkType: hard
"@fastify/error@npm:^3.0.0, @fastify/error@npm:^3.3.0, @fastify/error@npm:^3.4.0": "@fastify/error@npm:^4.0.0":
version: 3.4.1 version: 4.0.0
resolution: "@fastify/error@npm:3.4.1" resolution: "@fastify/error@npm:4.0.0"
checksum: 4d63660f7d4a0d6091abf869208d30898bde82f513ca7be542243d9d740df743dd4be293e7db30858fca612dd512d28a818ea06dc674e06b445278fcefcdda92 checksum: 9afdb1262fbd57e1c922cd7b3326c45d2ca018456030669dcad76feda60df894a3c25b9d019cd050ffc3686a0de938799be826328ab2d74257941788c7f642e7
languageName: node languageName: node
linkType: hard linkType: hard
"@fastify/fast-json-stringify-compiler@npm:^4.3.0": "@fastify/fast-json-stringify-compiler@npm:^5.0.0":
version: 4.3.0 version: 5.0.1
resolution: "@fastify/fast-json-stringify-compiler@npm:4.3.0" resolution: "@fastify/fast-json-stringify-compiler@npm:5.0.1"
dependencies: dependencies:
fast-json-stringify: "npm:^5.7.0" fast-json-stringify: "npm:^6.0.0"
checksum: 9ad575907d44bbd371dbc23a51853fd349a459092340fe91c50317f92707961f2e6ca6c9d17707a8e4a087c635e09bce1166e082d54f191769a582339c94badd checksum: 82c9b51cd096221b4dc191ffef01f4ccfda389bea08e218bd9926f99a0b6a10fadad47d9106335e1d48b160047178e14d8f87ee202fa5c2eab3957ae37d060c3
languageName: node languageName: node
linkType: hard linkType: hard
"@fastify/merge-json-schemas@npm:^0.1.0": "@fastify/merge-json-schemas@npm:^0.1.1":
version: 0.1.1 version: 0.1.1
resolution: "@fastify/merge-json-schemas@npm:0.1.1" resolution: "@fastify/merge-json-schemas@npm:0.1.1"
dependencies: dependencies:
@@ -117,17 +119,16 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@fastify/multipart@npm:^8.3.0": "@fastify/multipart@npm:^9.0.1":
version: 8.3.0 version: 9.0.1
resolution: "@fastify/multipart@npm:8.3.0" resolution: "@fastify/multipart@npm:9.0.1"
dependencies: dependencies:
"@fastify/busboy": "npm:^2.1.0" "@fastify/busboy": "npm:^3.0.0"
"@fastify/deepmerge": "npm:^1.0.0" "@fastify/deepmerge": "npm:^2.0.0"
"@fastify/error": "npm:^3.0.0" "@fastify/error": "npm:^4.0.0"
fastify-plugin: "npm:^4.0.0" fastify-plugin: "npm:^5.0.0"
secure-json-parse: "npm:^2.4.0" secure-json-parse: "npm:^3.0.0"
stream-wormhole: "npm:^1.1.0" checksum: c79c90366cf2bc062b75bb9672948b00f82a17a9b44b29457945d6760d07bdc444c497b051e27a1f0cf1879790fea2867d30cfc0ec6cc40144081793aef1198f
checksum: 23b9b709a499af0c0beaaaabd52032a92fa8f4a398ed821c2b4f272e68602ed7bcf91b5daed1e5270c3c61a8b3e8ea1bc2924f21fbcfdbdbd07f4342bd17cd81
languageName: node languageName: node
linkType: hard linkType: hard
@@ -231,9 +232,9 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/cli@npm:^0.3.12": "@swc/cli@npm:^0.5.0":
version: 0.3.12 version: 0.5.0
resolution: "@swc/cli@npm:0.3.12" resolution: "@swc/cli@npm:0.5.0"
dependencies: dependencies:
"@mole-inc/bin-wrapper": "npm:^8.0.1" "@mole-inc/bin-wrapper": "npm:^8.0.1"
"@swc/counter": "npm:^0.1.3" "@swc/counter": "npm:^0.1.3"
@@ -254,96 +255,96 @@ __metadata:
spack: bin/spack.js spack: bin/spack.js
swc: bin/swc.js swc: bin/swc.js
swcx: bin/swcx.js swcx: bin/swcx.js
checksum: fee260434fad8eed0328f4db17f42ce0864b93b90fcb02f3f0eb3aad994b5a6ae4bfdfb6d2329377e0cd8d07adc61cca42e290bf0005c1ab4d004d4a0b152db4 checksum: 033b682f1c25c8fae731414d2a463a0e455452bf9349c025cd88ea63ee1e5a589032eb206063fd925daf12065c9f1e5b4680cef50cc24674681c4d2583b7dca0
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-darwin-arm64@npm:1.6.3": "@swc/core-darwin-arm64@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-darwin-arm64@npm:1.6.3" resolution: "@swc/core-darwin-arm64@npm:1.9.2"
conditions: os=darwin & cpu=arm64 conditions: os=darwin & cpu=arm64
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-darwin-x64@npm:1.6.3": "@swc/core-darwin-x64@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-darwin-x64@npm:1.6.3" resolution: "@swc/core-darwin-x64@npm:1.9.2"
conditions: os=darwin & cpu=x64 conditions: os=darwin & cpu=x64
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-linux-arm-gnueabihf@npm:1.6.3": "@swc/core-linux-arm-gnueabihf@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-linux-arm-gnueabihf@npm:1.6.3" resolution: "@swc/core-linux-arm-gnueabihf@npm:1.9.2"
conditions: os=linux & cpu=arm conditions: os=linux & cpu=arm
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-linux-arm64-gnu@npm:1.6.3": "@swc/core-linux-arm64-gnu@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-linux-arm64-gnu@npm:1.6.3" resolution: "@swc/core-linux-arm64-gnu@npm:1.9.2"
conditions: os=linux & cpu=arm64 & libc=glibc conditions: os=linux & cpu=arm64 & libc=glibc
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-linux-arm64-musl@npm:1.6.3": "@swc/core-linux-arm64-musl@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-linux-arm64-musl@npm:1.6.3" resolution: "@swc/core-linux-arm64-musl@npm:1.9.2"
conditions: os=linux & cpu=arm64 & libc=musl conditions: os=linux & cpu=arm64 & libc=musl
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-linux-x64-gnu@npm:1.6.3": "@swc/core-linux-x64-gnu@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-linux-x64-gnu@npm:1.6.3" resolution: "@swc/core-linux-x64-gnu@npm:1.9.2"
conditions: os=linux & cpu=x64 & libc=glibc conditions: os=linux & cpu=x64 & libc=glibc
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-linux-x64-musl@npm:1.6.3": "@swc/core-linux-x64-musl@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-linux-x64-musl@npm:1.6.3" resolution: "@swc/core-linux-x64-musl@npm:1.9.2"
conditions: os=linux & cpu=x64 & libc=musl conditions: os=linux & cpu=x64 & libc=musl
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-win32-arm64-msvc@npm:1.6.3": "@swc/core-win32-arm64-msvc@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-win32-arm64-msvc@npm:1.6.3" resolution: "@swc/core-win32-arm64-msvc@npm:1.9.2"
conditions: os=win32 & cpu=arm64 conditions: os=win32 & cpu=arm64
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-win32-ia32-msvc@npm:1.6.3": "@swc/core-win32-ia32-msvc@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-win32-ia32-msvc@npm:1.6.3" resolution: "@swc/core-win32-ia32-msvc@npm:1.9.2"
conditions: os=win32 & cpu=ia32 conditions: os=win32 & cpu=ia32
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-win32-x64-msvc@npm:1.6.3": "@swc/core-win32-x64-msvc@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-win32-x64-msvc@npm:1.6.3" resolution: "@swc/core-win32-x64-msvc@npm:1.9.2"
conditions: os=win32 & cpu=x64 conditions: os=win32 & cpu=x64
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core@npm:^1.6.3": "@swc/core@npm:^1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core@npm:1.6.3" resolution: "@swc/core@npm:1.9.2"
dependencies: dependencies:
"@swc/core-darwin-arm64": "npm:1.6.3" "@swc/core-darwin-arm64": "npm:1.9.2"
"@swc/core-darwin-x64": "npm:1.6.3" "@swc/core-darwin-x64": "npm:1.9.2"
"@swc/core-linux-arm-gnueabihf": "npm:1.6.3" "@swc/core-linux-arm-gnueabihf": "npm:1.9.2"
"@swc/core-linux-arm64-gnu": "npm:1.6.3" "@swc/core-linux-arm64-gnu": "npm:1.9.2"
"@swc/core-linux-arm64-musl": "npm:1.6.3" "@swc/core-linux-arm64-musl": "npm:1.9.2"
"@swc/core-linux-x64-gnu": "npm:1.6.3" "@swc/core-linux-x64-gnu": "npm:1.9.2"
"@swc/core-linux-x64-musl": "npm:1.6.3" "@swc/core-linux-x64-musl": "npm:1.9.2"
"@swc/core-win32-arm64-msvc": "npm:1.6.3" "@swc/core-win32-arm64-msvc": "npm:1.9.2"
"@swc/core-win32-ia32-msvc": "npm:1.6.3" "@swc/core-win32-ia32-msvc": "npm:1.9.2"
"@swc/core-win32-x64-msvc": "npm:1.6.3" "@swc/core-win32-x64-msvc": "npm:1.9.2"
"@swc/counter": "npm:^0.1.3" "@swc/counter": "npm:^0.1.3"
"@swc/types": "npm:^0.1.8" "@swc/types": "npm:^0.1.15"
peerDependencies: peerDependencies:
"@swc/helpers": "*" "@swc/helpers": "*"
dependenciesMeta: dependenciesMeta:
@@ -370,7 +371,7 @@ __metadata:
peerDependenciesMeta: peerDependenciesMeta:
"@swc/helpers": "@swc/helpers":
optional: true optional: true
checksum: b4c84a083ecabb0280ba53dffa65a5a575321de94081ad52bd12027fe3b5c8957978f2211b6036e2e28d904dd046fca238106c2106b32d02b752808a51193d35 checksum: 6793f2014a016f90b1c41a695f6d3a14d574e129e78f651fe3d6dbacbc6d0836ab7a7eb445d873a302b060b25ae34c4e09d0f94574a71da47c6424c5fa58aa10
languageName: node languageName: node
linkType: hard linkType: hard
@@ -381,12 +382,12 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/types@npm:^0.1.8": "@swc/types@npm:^0.1.15":
version: 0.1.8 version: 0.1.15
resolution: "@swc/types@npm:0.1.8" resolution: "@swc/types@npm:0.1.15"
dependencies: dependencies:
"@swc/counter": "npm:^0.1.3" "@swc/counter": "npm:^0.1.3"
checksum: 2d1cda35116e03714137c1c37f4493efe0e26e88285ecc9dcdf6256a77984e367ea7b5f31d650f110fdcfd6ac53dff3ec77f841787ca328d2efa7b07ef1ac318 checksum: d8bf063aeebac51290d1edf0cec52e2e5b5afced0dc6933510a86947e10f0f77976bc14c3efb5e8f265a9cbdeb0929e00e44b2f82c6d0f273997c5029417b769
languageName: node languageName: node
linkType: hard linkType: hard
@@ -452,12 +453,12 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@types/node@npm:^20.14.6": "@types/node@npm:^22.9.0":
version: 20.14.6 version: 22.9.0
resolution: "@types/node@npm:20.14.6" resolution: "@types/node@npm:22.9.0"
dependencies: dependencies:
undici-types: "npm:~5.26.4" undici-types: "npm:~6.19.8"
checksum: 1dcfeeb03ce3c3a1d8a537fefee7cd0cffb78f89e9535b74ee12940559566b57c39dad20d1b165b60b5727408dd44e1a52e5c01cf02d0a99d93ef3da8062c86e checksum: a7df3426891868b0f5fb03e46aeddd8446178233521c624a44531c92a040cf08a82d8235f7e1e02af731fd16984665d4d71f3418caf9c2788313b10f040d615d
languageName: node languageName: node
linkType: hard linkType: hard
@@ -512,20 +513,6 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"ajv-formats@npm:^2.1.1":
version: 2.1.1
resolution: "ajv-formats@npm:2.1.1"
dependencies:
ajv: "npm:^8.0.0"
peerDependencies:
ajv: ^8.0.0
peerDependenciesMeta:
ajv:
optional: true
checksum: 70c263ded219bf277ffd9127f793b625f10a46113b2e901e150da41931fcfd7f5592da6d66862f4449bb157ffe65867c3294a7df1d661cc232c4163d5a1718ed
languageName: node
linkType: hard
"ajv-formats@npm:^3.0.1": "ajv-formats@npm:^3.0.1":
version: 3.0.1 version: 3.0.1
resolution: "ajv-formats@npm:3.0.1" resolution: "ajv-formats@npm:3.0.1"
@@ -540,7 +527,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"ajv@npm:^8.0.0, ajv@npm:^8.10.0, ajv@npm:^8.11.0": "ajv@npm:^8.0.0":
version: 8.16.0 version: 8.16.0
resolution: "ajv@npm:8.16.0" resolution: "ajv@npm:8.16.0"
dependencies: dependencies:
@@ -552,6 +539,18 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"ajv@npm:^8.12.0":
version: 8.17.1
resolution: "ajv@npm:8.17.1"
dependencies:
fast-deep-equal: "npm:^3.1.3"
fast-uri: "npm:^3.0.1"
json-schema-traverse: "npm:^1.0.0"
require-from-string: "npm:^2.0.2"
checksum: ee3c62162c953e91986c838f004132b6a253d700f1e51253b99791e2dbfdb39161bc950ebdc2f156f8568035bb5ed8be7bd78289cd9ecbf3381fe8f5b82e3f33
languageName: node
linkType: hard
"amqplib@npm:^0.10.4": "amqplib@npm:^0.10.4":
version: 0.10.4 version: 0.10.4
resolution: "amqplib@npm:0.10.4" resolution: "amqplib@npm:0.10.4"
@@ -608,13 +607,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"avvio@npm:^8.3.0": "avvio@npm:^9.0.0":
version: 8.3.2 version: 9.1.0
resolution: "avvio@npm:8.3.2" resolution: "avvio@npm:9.1.0"
dependencies: dependencies:
"@fastify/error": "npm:^3.3.0" "@fastify/error": "npm:^4.0.0"
fastq: "npm:^1.17.1" fastq: "npm:^1.17.1"
checksum: 5edef27388ac4c3f07453460b1cc66bad9ae9be2af9b55150ddf720729e2bf12be1dd81c822744363fdea4bb682edcf4c28d8235114e17b78f85f5c398e5bf68 checksum: 4bc7c0ac1b9e3a814db4bc5b89fd6a38b082614677d9a4e2d2b9c11bc830deac81dd0e5bdae4ba31b1e165c19de9f2772564fd3b840b3bfa5048f757bb6a4eda
languageName: node languageName: node
linkType: hard linkType: hard
@@ -802,10 +801,10 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"cookie@npm:^0.6.0": "cookie@npm:^1.0.1":
version: 0.6.0 version: 1.0.1
resolution: "cookie@npm:0.6.0" resolution: "cookie@npm:1.0.1"
checksum: c1f8f2ea7d443b9331680598b0ae4e6af18a618c37606d1bbdc75bec8361cce09fe93e727059a673f2ba24467131a9fb5a4eec76bb1b149c1b3e1ccb268dc583 checksum: 4b24d4fad5ba94ab76d74a8fc33ae1dcdb5dc02013e03e9577b26f019d9dfe396ffb9b3711ba1726bcfa1b93c33d117db0f31e187838aed7753dee1abc691688
languageName: node languageName: node
linkType: hard linkType: hard
@@ -842,17 +841,17 @@ __metadata:
version: 0.0.0-use.local version: 0.0.0-use.local
resolution: "dd-bigbot@workspace:." resolution: "dd-bigbot@workspace:."
dependencies: dependencies:
"@discordeno/bot": "npm:19.0.0-next.92bf166" "@discordeno/bot": "npm:19.0.0"
"@fastify/multipart": "npm:^8.3.0" "@fastify/multipart": "npm:^9.0.1"
"@influxdata/influxdb-client": "npm:^1.33.2" "@influxdata/influxdb-client": "npm:^1.33.2"
"@swc/cli": "npm:^0.3.12" "@swc/cli": "npm:^0.5.0"
"@swc/core": "npm:^1.6.3" "@swc/core": "npm:^1.9.2"
"@types/amqplib": "npm:^0.10.5" "@types/amqplib": "npm:^0.10.5"
"@types/node": "npm:^20.14.6" "@types/node": "npm:^22.9.0"
amqplib: "npm:^0.10.4" amqplib: "npm:^0.10.4"
chalk: "npm:^5.3.0" chalk: "npm:^5.3.0"
fastify: "npm:^4.28.0" fastify: "npm:^5.1.0"
typescript: "npm:^5.5.2" typescript: "npm:^5.6.3"
languageName: unknown languageName: unknown
linkType: soft linkType: soft
@@ -884,13 +883,6 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"dotenv@npm:^16.4.5":
version: 16.4.5
resolution: "dotenv@npm:16.4.5"
checksum: 55a3134601115194ae0f924e54473459ed0d9fc340ae610b676e248cca45aa7c680d86365318ea964e6da4e2ea80c4514c1adab5adb43d6867fb57ff068f95c8
languageName: node
linkType: hard
"eastasianwidth@npm:^0.2.0": "eastasianwidth@npm:^0.2.0":
version: 0.2.0 version: 0.2.0
resolution: "eastasianwidth@npm:0.2.0" resolution: "eastasianwidth@npm:0.2.0"
@@ -1032,13 +1024,6 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"fast-content-type-parse@npm:^1.1.0":
version: 1.1.0
resolution: "fast-content-type-parse@npm:1.1.0"
checksum: 8637228a19b11296992af5d9b5f5ae84c6f27a465cf36a901b303b784ce0ca6f10502375da59958eb2b9c4949b98e5cc460ecb4bd777d22c3fa236c1e8da1ed8
languageName: node
linkType: hard
"fast-decode-uri-component@npm:^1.0.1": "fast-decode-uri-component@npm:^1.0.1":
version: 1.0.1 version: 1.0.1
resolution: "fast-decode-uri-component@npm:1.0.1" resolution: "fast-decode-uri-component@npm:1.0.1"
@@ -1066,18 +1051,18 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"fast-json-stringify@npm:^5.7.0, fast-json-stringify@npm:^5.8.0": "fast-json-stringify@npm:^6.0.0":
version: 5.16.0 version: 6.0.0
resolution: "fast-json-stringify@npm:5.16.0" resolution: "fast-json-stringify@npm:6.0.0"
dependencies: dependencies:
"@fastify/merge-json-schemas": "npm:^0.1.0" "@fastify/merge-json-schemas": "npm:^0.1.1"
ajv: "npm:^8.10.0" ajv: "npm:^8.12.0"
ajv-formats: "npm:^3.0.1" ajv-formats: "npm:^3.0.1"
fast-deep-equal: "npm:^3.1.3" fast-deep-equal: "npm:^3.1.3"
fast-uri: "npm:^2.1.0" fast-uri: "npm:^2.3.0"
json-schema-ref-resolver: "npm:^1.0.1" json-schema-ref-resolver: "npm:^1.0.1"
rfdc: "npm:^1.2.0" rfdc: "npm:^1.2.0"
checksum: 06ae46bba0d362c515aed21326cd9496723dd34422b7d86a5da7442807b9b02ecea856e4ed42b4aa96dce61c806c2bf29eb483efa17ef63a4ff76aab3c2cc21b checksum: b850b0669d6e2807e07c6e07a6d95224132a26d2759a86eb070ad4ad1103aafa08e63c3eca554eca701d77abd3b96037d2b70aead14aa93bd4c4e67ba2a57bd0
languageName: node languageName: node
linkType: hard linkType: hard
@@ -1097,41 +1082,47 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"fast-uri@npm:^2.0.0, fast-uri@npm:^2.1.0": "fast-uri@npm:^2.3.0":
version: 2.3.1 version: 2.4.0
resolution: "fast-uri@npm:2.3.1" resolution: "fast-uri@npm:2.4.0"
checksum: 362e90cafd6fa1700ce12eb2f10a21e02a5b6c016f9f015eeb2b65f450775d8341e3fd4022f09134d3cf1415b112777c4502f3e9da009699dcc78053a641fba5 checksum: 07338f5665c29697ed5359c8010e58450b5c3fee2e9a3d6457e8b4a045995a36a7b9062c9849dad4ffe8959d3e150beccb78beecaab84f6b5f0976a2360f3028
languageName: node languageName: node
linkType: hard linkType: hard
"fastify-plugin@npm:^4.0.0": "fast-uri@npm:^3.0.0, fast-uri@npm:^3.0.1":
version: 4.5.1 version: 3.0.3
resolution: "fastify-plugin@npm:4.5.1" resolution: "fast-uri@npm:3.0.3"
checksum: 7c6d777ada0f01c8a1166a2a669cccfd6074c7764121f07cce997745f198227a271c7a317aaf0da273b329f24307f0eba3f093d872d29b839b33deb525bbafe2 checksum: 92487c75848b03edc45517fca0148287d342c30818ce43d556391db774d8e01644fb6964315a3336eec5a90f301b218b21f71fb9b2528ba25757435a20392c95
languageName: node languageName: node
linkType: hard linkType: hard
"fastify@npm:^4.28.0": "fastify-plugin@npm:^5.0.0":
version: 4.28.0 version: 5.0.1
resolution: "fastify@npm:4.28.0" resolution: "fastify-plugin@npm:5.0.1"
checksum: 76f6960558239d1ead520ecfb9dbb9b0435a63376d9d48bed0861609a909bf1958cb097745bb1a5485592f2c6d1438941e7481203c86b0e74d2bc34f09e8ed3e
languageName: node
linkType: hard
"fastify@npm:^5.1.0":
version: 5.1.0
resolution: "fastify@npm:5.1.0"
dependencies: dependencies:
"@fastify/ajv-compiler": "npm:^3.5.0" "@fastify/ajv-compiler": "npm:^4.0.0"
"@fastify/error": "npm:^3.4.0" "@fastify/error": "npm:^4.0.0"
"@fastify/fast-json-stringify-compiler": "npm:^4.3.0" "@fastify/fast-json-stringify-compiler": "npm:^5.0.0"
abstract-logging: "npm:^2.0.1" abstract-logging: "npm:^2.0.1"
avvio: "npm:^8.3.0" avvio: "npm:^9.0.0"
fast-content-type-parse: "npm:^1.1.0" fast-json-stringify: "npm:^6.0.0"
fast-json-stringify: "npm:^5.8.0" find-my-way: "npm:^9.0.0"
find-my-way: "npm:^8.0.0" light-my-request: "npm:^6.0.0"
light-my-request: "npm:^5.11.0"
pino: "npm:^9.0.0" pino: "npm:^9.0.0"
process-warning: "npm:^3.0.0" process-warning: "npm:^4.0.0"
proxy-addr: "npm:^2.0.7" proxy-addr: "npm:^2.0.7"
rfdc: "npm:^1.3.0" rfdc: "npm:^1.3.1"
secure-json-parse: "npm:^2.7.0" secure-json-parse: "npm:^2.7.0"
semver: "npm:^7.5.4" semver: "npm:^7.6.0"
toad-cache: "npm:^3.3.0" toad-cache: "npm:^3.7.0"
checksum: 8f3991b1ae2b5248ca9fb09f57f0fc083ca3ca26ab418fb2b0b768c5cec5c01aa4aaa9e7697018457a5f53fe43d74747bac2393509eeac96bb535d5cbba4e062 checksum: 32ad1a2fcb1206f42ef8f600f59c11b6bba8b41c9c4b97dda895ecfd265f0127c0b9019335923b0208db73ca835ef996af65e6a62fe106a274f8e3973dcfd65d
languageName: node languageName: node
linkType: hard linkType: hard
@@ -1182,14 +1173,14 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"find-my-way@npm:^8.0.0": "find-my-way@npm:^9.0.0":
version: 8.2.2 version: 9.1.0
resolution: "find-my-way@npm:8.2.2" resolution: "find-my-way@npm:9.1.0"
dependencies: dependencies:
fast-deep-equal: "npm:^3.1.3" fast-deep-equal: "npm:^3.1.3"
fast-querystring: "npm:^1.0.0" fast-querystring: "npm:^1.0.0"
safe-regex2: "npm:^3.1.0" safe-regex2: "npm:^4.0.0"
checksum: 8a3e7531a7471d1ea93e77d4e486f4ca8c42fc0349efaaefba197cabf4e2fa62f4ae65866b34702eb74c7f2caf9121d26e04c9f4b25db76310b5399a6db7f5a5 checksum: 7c73ac979205ca78a35dfcdf1eb63bf8d88c3c545cf75bc2afd4e53bd8958aef4cfd25dcb86f8a870dee2ae5a95a79ffa3614d730fe88cf810f05e40fcf1652e
languageName: node languageName: node
linkType: hard linkType: hard
@@ -1237,6 +1228,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"fzstd@npm:^0.1.1":
version: 0.1.1
resolution: "fzstd@npm:0.1.1"
checksum: 455b968aeb764f06d9c39a5c8b45eefd645f7ee9129896e890eafb8ab367482f8495de12907021a32f6544494305a42a2056c30c63efac06181e6efcdab3fe78
languageName: node
linkType: hard
"get-stream@npm:^3.0.0": "get-stream@npm:^3.0.0":
version: 3.0.0 version: 3.0.0
resolution: "get-stream@npm:3.0.0" resolution: "get-stream@npm:3.0.0"
@@ -1539,14 +1537,14 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"light-my-request@npm:^5.11.0": "light-my-request@npm:^6.0.0":
version: 5.13.0 version: 6.3.0
resolution: "light-my-request@npm:5.13.0" resolution: "light-my-request@npm:6.3.0"
dependencies: dependencies:
cookie: "npm:^0.6.0" cookie: "npm:^1.0.1"
process-warning: "npm:^3.0.0" process-warning: "npm:^4.0.0"
set-cookie-parser: "npm:^2.4.1" set-cookie-parser: "npm:^2.6.0"
checksum: 29407ecd0fcc240fbc4ac53457247e7f796962aaa228e9c5057bb4a7d84fda4f14eaaf39212f2dbfe0869b78a2a42ec82ec4a597a181b9ee19ac23a636c0160d checksum: 8e00804245a59420d5b95f21946cddd375b49f5d5b22da142febaceb6a928b7b806e424c7b62a4734bcca02e55c1b56612253daf17771167cc453e59160cef67
languageName: node languageName: node
linkType: hard linkType: hard
@@ -2022,6 +2020,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"process-warning@npm:^4.0.0":
version: 4.0.0
resolution: "process-warning@npm:4.0.0"
checksum: 0d6ec069f3a6fe1d3379c0247329a297f1f3b9ea7e1d828db0a8f61e0e8337a98b7eb201547350924bc4a101ddcf2fa5cf5563ffe2c54c27651f7996d328483e
languageName: node
linkType: hard
"process@npm:^0.11.10": "process@npm:^0.11.10":
version: 0.11.10 version: 0.11.10
resolution: "process@npm:0.11.10" resolution: "process@npm:0.11.10"
@@ -2183,10 +2188,10 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"ret@npm:~0.4.0": "ret@npm:~0.5.0":
version: 0.4.3 version: 0.5.0
resolution: "ret@npm:0.4.3" resolution: "ret@npm:0.5.0"
checksum: d6a00f0920400b78b6aa96ce1c953d2f783f4fd5d56b5e842a744c40e33545e7955fb132386ada406361881353292fe7282f4e6e82b2c1e61f6c96a6ea4bb2d7 checksum: fb58f61268ceb762de471fd5871a53def1f47160487c6e21dcbe5274b3eb2df40a80d9eab7ed3732c8de4e4fadc911a66a190a129b5cf75c3e70302a7607f82f
languageName: node languageName: node
linkType: hard linkType: hard
@@ -2204,13 +2209,20 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"rfdc@npm:^1.2.0, rfdc@npm:^1.3.0": "rfdc@npm:^1.2.0":
version: 1.3.1 version: 1.3.1
resolution: "rfdc@npm:1.3.1" resolution: "rfdc@npm:1.3.1"
checksum: 44cc6a82e2fe1db13b7d3c54e9ffd0b40ef070cbde69ffbfbb38dab8cee46bd68ba686784b96365ff08d04798bc121c3465663a0c91f2c421c90546c4366f4a6 checksum: 44cc6a82e2fe1db13b7d3c54e9ffd0b40ef070cbde69ffbfbb38dab8cee46bd68ba686784b96365ff08d04798bc121c3465663a0c91f2c421c90546c4366f4a6
languageName: node languageName: node
linkType: hard linkType: hard
"rfdc@npm:^1.3.1":
version: 1.4.1
resolution: "rfdc@npm:1.4.1"
checksum: 2f3d11d3d8929b4bfeefc9acb03aae90f971401de0add5ae6c5e38fec14f0405e6a4aad8fdb76344bfdd20c5193110e3750cbbd28ba86d73729d222b6cf4a729
languageName: node
linkType: hard
"run-parallel@npm:^1.1.9": "run-parallel@npm:^1.1.9":
version: 1.2.0 version: 1.2.0
resolution: "run-parallel@npm:1.2.0" resolution: "run-parallel@npm:1.2.0"
@@ -2234,12 +2246,12 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"safe-regex2@npm:^3.1.0": "safe-regex2@npm:^4.0.0":
version: 3.1.0 version: 4.0.0
resolution: "safe-regex2@npm:3.1.0" resolution: "safe-regex2@npm:4.0.0"
dependencies: dependencies:
ret: "npm:~0.4.0" ret: "npm:~0.5.0"
checksum: 4f9f7172662763619052a45599e515efc5dd10a932690f610c8ab808a4baa41be3feafefa444f7532651d721d12871a1c9a85330626cdd013b804e8f4240dff1 checksum: 5607d4c20a92d66905d33556807da759ef0615d3b508ae7d6e7558e763bd59042bd30afb32d5f2456eb3f69a9d86fadbdf5e3e292494dae89fdae3087532602e
languageName: node languageName: node
linkType: hard linkType: hard
@@ -2257,13 +2269,20 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"secure-json-parse@npm:^2.4.0, secure-json-parse@npm:^2.7.0": "secure-json-parse@npm:^2.7.0":
version: 2.7.0 version: 2.7.0
resolution: "secure-json-parse@npm:2.7.0" resolution: "secure-json-parse@npm:2.7.0"
checksum: 974386587060b6fc5b1ac06481b2f9dbbb0d63c860cc73dc7533f27835fdb67b0ef08762dbfef25625c15bc0a0c366899e00076cb0d556af06b71e22f1dede4c checksum: 974386587060b6fc5b1ac06481b2f9dbbb0d63c860cc73dc7533f27835fdb67b0ef08762dbfef25625c15bc0a0c366899e00076cb0d556af06b71e22f1dede4c
languageName: node languageName: node
linkType: hard linkType: hard
"secure-json-parse@npm:^3.0.0":
version: 3.0.0
resolution: "secure-json-parse@npm:3.0.0"
checksum: 7376fb1ee470d311976329a2734e36aa7e282b3833cf765510ac2cfac70f923500c7bb5230f980062366fc2a607b7d3705948d87bb24db1c323dfd1591f1b0de
languageName: node
linkType: hard
"semver-regex@npm:^4.0.5": "semver-regex@npm:^4.0.5":
version: 4.0.5 version: 4.0.5
resolution: "semver-regex@npm:4.0.5" resolution: "semver-regex@npm:4.0.5"
@@ -2280,7 +2299,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"semver@npm:^7.3.5, semver@npm:^7.3.8, semver@npm:^7.5.3, semver@npm:^7.5.4": "semver@npm:^7.3.5, semver@npm:^7.3.8, semver@npm:^7.5.3":
version: 7.6.2 version: 7.6.2
resolution: "semver@npm:7.6.2" resolution: "semver@npm:7.6.2"
bin: bin:
@@ -2289,10 +2308,19 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"set-cookie-parser@npm:^2.4.1": "semver@npm:^7.6.0":
version: 2.6.0 version: 7.6.3
resolution: "set-cookie-parser@npm:2.6.0" resolution: "semver@npm:7.6.3"
checksum: 8d451ebadb760989f93b634942c79de3c925ca7a986d133d08a80c40b5ae713ce12e354f0d5245c49f288c52daa7bd6554d5dc52f8a4eecaaf5e192881cf2b1f bin:
semver: bin/semver.js
checksum: 36b1fbe1a2b6f873559cd57b238f1094a053dbfd997ceeb8757d79d1d2089c56d1321b9f1069ce263dc64cfa922fa1d2ad566b39426fe1ac6c723c1487589e10
languageName: node
linkType: hard
"set-cookie-parser@npm:^2.6.0":
version: 2.7.1
resolution: "set-cookie-parser@npm:2.7.1"
checksum: c92b1130032693342bca13ea1b1bc93967ab37deec4387fcd8c2a843c0ef2fd9a9f3df25aea5bb3976cd05a91c2cf4632dd6164d6e1814208fb7d7e14edd42b4
languageName: node languageName: node
linkType: hard linkType: hard
@@ -2434,13 +2462,6 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"stream-wormhole@npm:^1.1.0":
version: 1.1.0
resolution: "stream-wormhole@npm:1.1.0"
checksum: cc19e0235c5d031bd530fa83913c807d9525fa4ba33d51691dd822c0726b8b7ef138b34f289d063a3018cddba67d3ba7fd0ecedaa97242a0f1ed2eed3c6a2ab1
languageName: node
linkType: hard
"string-width-cjs@npm:string-width@^4.2.0, string-width@npm:^4.1.0": "string-width-cjs@npm:string-width@^4.2.0, string-width@npm:^4.1.0":
version: 4.2.3 version: 4.2.3
resolution: "string-width@npm:4.2.3" resolution: "string-width@npm:4.2.3"
@@ -2560,7 +2581,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"toad-cache@npm:^3.3.0": "toad-cache@npm:^3.7.0":
version: 3.7.0 version: 3.7.0
resolution: "toad-cache@npm:3.7.0" resolution: "toad-cache@npm:3.7.0"
checksum: cdc62aacc047e94eab21697943e117bbb1938168a03e5e85fdba28ab6ea66f4796ff16b219019a64d2115048378f9dd1f4e62c78c1f1d4961d0b3d23f9a9374d checksum: cdc62aacc047e94eab21697943e117bbb1938168a03e5e85fdba28ab6ea66f4796ff16b219019a64d2115048378f9dd1f4e62c78c1f1d4961d0b3d23f9a9374d
@@ -2586,30 +2607,23 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"tweetnacl@npm:^1.0.3": "typescript@npm:^5.6.3":
version: 1.0.3 version: 5.6.3
resolution: "tweetnacl@npm:1.0.3" resolution: "typescript@npm:5.6.3"
checksum: ca122c2f86631f3c0f6d28efb44af2a301d4a557a62a3e2460286b08e97567b258c2212e4ad1cfa22bd6a57edcdc54ba76ebe946847450ab0999e6d48ccae332
languageName: node
linkType: hard
"typescript@npm:^5.5.2":
version: 5.5.2
resolution: "typescript@npm:5.5.2"
bin: bin:
tsc: bin/tsc tsc: bin/tsc
tsserver: bin/tsserver tsserver: bin/tsserver
checksum: 9118b20f248e76b0dbff8737fef65dfa89d02668d4e633d2c5ceac99033a0ca5e8a1c1a53bc94da68e8f67677a88f318663dde859c9e9a09c1e116415daec2ba checksum: c328e418e124b500908781d9f7b9b93cf08b66bf5936d94332b463822eea2f4e62973bfb3b8a745fdc038785cb66cf59d1092bac3ec2ac6a3e5854687f7833f1
languageName: node languageName: node
linkType: hard linkType: hard
"typescript@patch:typescript@npm%3A^5.5.2#optional!builtin<compat/typescript>": "typescript@patch:typescript@npm%3A^5.6.3#optional!builtin<compat/typescript>":
version: 5.5.2 version: 5.6.3
resolution: "typescript@patch:typescript@npm%3A5.5.2#optional!builtin<compat/typescript>::version=5.5.2&hash=e012d7" resolution: "typescript@patch:typescript@npm%3A5.6.3#optional!builtin<compat/typescript>::version=5.6.3&hash=e012d7"
bin: bin:
tsc: bin/tsc tsc: bin/tsc
tsserver: bin/tsserver tsserver: bin/tsserver
checksum: 28b3de2ddaf63a7620e7ddbe5d377af71ce93ecc558c41bf0e3d88661d8e6e7aa6c7739164fef98055f69819e41faca49252938ef3633a3dff2734cca6a9042e checksum: dc4bec403cd33a204b655b1152a096a08e7bad2c931cb59ef8ff26b6f2aa541bf98f09fc157958a60c921b1983a8dde9a85b692f9de60fa8f574fd131e3ae4dd
languageName: node languageName: node
linkType: hard linkType: hard
@@ -2620,6 +2634,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"undici-types@npm:~6.19.8":
version: 6.19.8
resolution: "undici-types@npm:6.19.8"
checksum: cf0b48ed4fc99baf56584afa91aaffa5010c268b8842f62e02f752df209e3dea138b372a60a963b3b2576ed932f32329ce7ddb9cb5f27a6c83040d8cd74b7a70
languageName: node
linkType: hard
"unique-filename@npm:^3.0.0": "unique-filename@npm:^3.0.0":
version: 3.0.0 version: 3.0.0
resolution: "unique-filename@npm:3.0.0" resolution: "unique-filename@npm:3.0.0"
@@ -2726,7 +2747,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"ws@npm:^8.16.0": "ws@npm:^8.18.0":
version: 8.18.0 version: 8.18.0
resolution: "ws@npm:8.18.0" resolution: "ws@npm:8.18.0"
peerDependencies: peerDependencies:
+5 -5
View File
@@ -13,14 +13,14 @@
"setup-dd": "" "setup-dd": ""
}, },
"dependencies": { "dependencies": {
"@discordeno/bot": "19.0.0-next.92bf166", "@discordeno/bot": "19.0.0",
"chalk": "^5.3.0", "chalk": "^5.3.0",
"dotenv": "^16.4.5" "dotenv": "^16.4.5"
}, },
"devDependencies": { "devDependencies": {
"@swc/cli": "^0.3.12", "@swc/cli": "^0.5.0",
"@swc/core": "^1.6.3", "@swc/core": "^1.9.2",
"@types/node": "^20.14.6", "@types/node": "^22.9.0",
"typescript": "^5.5.2" "typescript": "^5.6.3"
} }
} }
+10 -10
View File
@@ -1,23 +1,23 @@
import { type Bot, Collection, Intents, createBot } from '@discordeno/bot' import { Collection, Intents, createBot } from '@discordeno/bot'
import { configs } from './config.js' import { configs } from './config.js'
import type { Command } from './types/commands.js' import type { Command } from './types/commands.js'
const rawBot = createBot({ const rawBot = createBot({
token: configs.token, token: configs.token,
intents: Intents.Guilds, intents: Intents.Guilds,
desiredProperties: {
interaction: {
id: true,
type: true,
data: true,
token: true,
},
},
}) })
// Setup desired properties
rawBot.transformers.desiredProperties.interaction.id = true
rawBot.transformers.desiredProperties.interaction.type = true
rawBot.transformers.desiredProperties.interaction.data = true
rawBot.transformers.desiredProperties.interaction.token = true
export const bot = rawBot as BotWithCommands export const bot = rawBot as BotWithCommands
// Create the command collection // Create the command collection
bot.commands = new Collection() bot.commands = new Collection()
export interface BotWithCommands extends Bot { export type BotWithCommands = typeof rawBot & { commands: Collection<string, Command> }
commands: Collection<string, Command>
}
+3 -2
View File
@@ -1,4 +1,5 @@
import type { ApplicationCommandOption, ApplicationCommandTypes, Interaction } from '@discordeno/bot' import type { ApplicationCommandOption, ApplicationCommandTypes } from '@discordeno/bot'
import type { bot } from '../bot.js'
export interface Command { export interface Command {
/** The name of this command. */ /** The name of this command. */
@@ -12,5 +13,5 @@ export interface Command {
/** The options for this command */ /** The options for this command */
options?: ApplicationCommandOption[] options?: ApplicationCommandOption[]
/** This will be executed when the command is run. */ /** This will be executed when the command is run. */
execute: (interaction: Interaction) => unknown execute: (interaction: typeof bot.transformers.$inferredTypes.interaction) => unknown
} }
+120 -111
View File
@@ -5,54 +5,56 @@ __metadata:
version: 8 version: 8
cacheKey: 10 cacheKey: 10
"@discordeno/bot@npm:19.0.0-next.92bf166": "@discordeno/bot@npm:19.0.0":
version: 19.0.0-next.92bf166 version: 19.0.0
resolution: "@discordeno/bot@npm:19.0.0-next.92bf166" resolution: "@discordeno/bot@npm:19.0.0"
dependencies: dependencies:
"@discordeno/gateway": "npm:19.0.0-next.92bf166" "@discordeno/gateway": "npm:19.0.0"
"@discordeno/rest": "npm:19.0.0-next.92bf166" "@discordeno/rest": "npm:19.0.0"
"@discordeno/types": "npm:19.0.0-next.92bf166" "@discordeno/types": "npm:19.0.0"
"@discordeno/utils": "npm:19.0.0-next.92bf166" "@discordeno/utils": "npm:19.0.0"
checksum: 3020e74c774eae34307d434ad38f983e90839dc5fad7578f3cda4fba6c1efb7a22c4f4cdcfff58c54b62cc14976ad974256955d5117e490f78ec9e835e02c682 checksum: 86ac4cd61761c1b3c3fa82db08742dcdba18ffb1b6042455c8a5e8cdd02231543c3c2d43dfb29084d44034cafebdc6ab51969c5930281ab2be83d5b159b69726
languageName: node languageName: node
linkType: hard linkType: hard
"@discordeno/gateway@npm:19.0.0-next.92bf166": "@discordeno/gateway@npm:19.0.0":
version: 19.0.0-next.92bf166 version: 19.0.0
resolution: "@discordeno/gateway@npm:19.0.0-next.92bf166" resolution: "@discordeno/gateway@npm:19.0.0"
dependencies: dependencies:
"@discordeno/types": "npm:19.0.0-next.92bf166" "@discordeno/types": "npm:19.0.0"
"@discordeno/utils": "npm:19.0.0-next.92bf166" "@discordeno/utils": "npm:19.0.0"
ws: "npm:^8.16.0" fzstd: "npm:^0.1.1"
checksum: 6a11ca7a4cb98f48726664d0baa27d04e26342bf94d6e439494e462636af20d17b567e9d3e2e478465aabcecb98a21e54b860b39b9f1022eef922e76d947ddcb ws: "npm:^8.18.0"
dependenciesMeta:
fzstd:
optional: true
checksum: 241ec9981bf47ff894990889477fbc1ce91361648534189361e9dca4d927aba15c941604da29ba135cb20871fac7e82e5cc1eed1df6ef3d86bbcdfdca3448649
languageName: node languageName: node
linkType: hard linkType: hard
"@discordeno/rest@npm:19.0.0-next.92bf166": "@discordeno/rest@npm:19.0.0":
version: 19.0.0-next.92bf166 version: 19.0.0
resolution: "@discordeno/rest@npm:19.0.0-next.92bf166" resolution: "@discordeno/rest@npm:19.0.0"
dependencies: dependencies:
"@discordeno/types": "npm:19.0.0-next.92bf166" "@discordeno/types": "npm:19.0.0"
"@discordeno/utils": "npm:19.0.0-next.92bf166" "@discordeno/utils": "npm:19.0.0"
dotenv: "npm:^16.4.5" checksum: e1ce6c092566e58c5d407a5fee7c6c38f988251abcbaaf14beaa084691b4c52dc4f6c54f46974735090fafe174b1914374edd074bffd441e11d76851575a136f
checksum: 45f6ba4791003b77c883e991ad348597197d70e25e335b8628a03bd2effa8e2047a2f987f4c0b6ee8b17c01f77055d7a1ddc9f5350eb8f1c8ff8c8d39f91d787
languageName: node languageName: node
linkType: hard linkType: hard
"@discordeno/types@npm:19.0.0-next.92bf166": "@discordeno/types@npm:19.0.0":
version: 19.0.0-next.92bf166 version: 19.0.0
resolution: "@discordeno/types@npm:19.0.0-next.92bf166" resolution: "@discordeno/types@npm:19.0.0"
checksum: f88e78a18e51c179b94ef14e8bcdd6b5e6c5f25bdd6c4308bec121e5e59533612b36ed0e7a447daedc009053e1e30c6c8e13b2276bb1ce7e2f840ff58473a2ef checksum: aaf832d6510b7aa0ead75bd5c1d1990f3a77fa980d40122d6d092abc571280aed6864b10fdda705d70bd7ba73961f4b3a0ee28c6b7cabb09595574f65fcfd61c
languageName: node languageName: node
linkType: hard linkType: hard
"@discordeno/utils@npm:19.0.0-next.92bf166": "@discordeno/utils@npm:19.0.0":
version: 19.0.0-next.92bf166 version: 19.0.0
resolution: "@discordeno/utils@npm:19.0.0-next.92bf166" resolution: "@discordeno/utils@npm:19.0.0"
dependencies: dependencies:
"@discordeno/types": "npm:19.0.0-next.92bf166" "@discordeno/types": "npm:19.0.0"
tweetnacl: "npm:^1.0.3" checksum: b2d430099672cfb8b68d6a9bd12803cd69cb909dc1f368d8305a4bb1067499babff05997a29599b51029d0add435bea4a03929140abf77dd83e1741baaa37855
checksum: 7962a057ba5908936e4224df70b9ceaffcb8ec7ad220a999b36fc0601365b380bb0de01b6adfa4c36250247e3d15e22215fc63bbe3634b932434411c5f4ca13d
languageName: node languageName: node
linkType: hard linkType: hard
@@ -149,9 +151,9 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/cli@npm:^0.3.12": "@swc/cli@npm:^0.5.0":
version: 0.3.12 version: 0.5.0
resolution: "@swc/cli@npm:0.3.12" resolution: "@swc/cli@npm:0.5.0"
dependencies: dependencies:
"@mole-inc/bin-wrapper": "npm:^8.0.1" "@mole-inc/bin-wrapper": "npm:^8.0.1"
"@swc/counter": "npm:^0.1.3" "@swc/counter": "npm:^0.1.3"
@@ -172,96 +174,96 @@ __metadata:
spack: bin/spack.js spack: bin/spack.js
swc: bin/swc.js swc: bin/swc.js
swcx: bin/swcx.js swcx: bin/swcx.js
checksum: fee260434fad8eed0328f4db17f42ce0864b93b90fcb02f3f0eb3aad994b5a6ae4bfdfb6d2329377e0cd8d07adc61cca42e290bf0005c1ab4d004d4a0b152db4 checksum: 033b682f1c25c8fae731414d2a463a0e455452bf9349c025cd88ea63ee1e5a589032eb206063fd925daf12065c9f1e5b4680cef50cc24674681c4d2583b7dca0
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-darwin-arm64@npm:1.6.3": "@swc/core-darwin-arm64@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-darwin-arm64@npm:1.6.3" resolution: "@swc/core-darwin-arm64@npm:1.9.2"
conditions: os=darwin & cpu=arm64 conditions: os=darwin & cpu=arm64
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-darwin-x64@npm:1.6.3": "@swc/core-darwin-x64@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-darwin-x64@npm:1.6.3" resolution: "@swc/core-darwin-x64@npm:1.9.2"
conditions: os=darwin & cpu=x64 conditions: os=darwin & cpu=x64
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-linux-arm-gnueabihf@npm:1.6.3": "@swc/core-linux-arm-gnueabihf@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-linux-arm-gnueabihf@npm:1.6.3" resolution: "@swc/core-linux-arm-gnueabihf@npm:1.9.2"
conditions: os=linux & cpu=arm conditions: os=linux & cpu=arm
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-linux-arm64-gnu@npm:1.6.3": "@swc/core-linux-arm64-gnu@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-linux-arm64-gnu@npm:1.6.3" resolution: "@swc/core-linux-arm64-gnu@npm:1.9.2"
conditions: os=linux & cpu=arm64 & libc=glibc conditions: os=linux & cpu=arm64 & libc=glibc
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-linux-arm64-musl@npm:1.6.3": "@swc/core-linux-arm64-musl@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-linux-arm64-musl@npm:1.6.3" resolution: "@swc/core-linux-arm64-musl@npm:1.9.2"
conditions: os=linux & cpu=arm64 & libc=musl conditions: os=linux & cpu=arm64 & libc=musl
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-linux-x64-gnu@npm:1.6.3": "@swc/core-linux-x64-gnu@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-linux-x64-gnu@npm:1.6.3" resolution: "@swc/core-linux-x64-gnu@npm:1.9.2"
conditions: os=linux & cpu=x64 & libc=glibc conditions: os=linux & cpu=x64 & libc=glibc
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-linux-x64-musl@npm:1.6.3": "@swc/core-linux-x64-musl@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-linux-x64-musl@npm:1.6.3" resolution: "@swc/core-linux-x64-musl@npm:1.9.2"
conditions: os=linux & cpu=x64 & libc=musl conditions: os=linux & cpu=x64 & libc=musl
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-win32-arm64-msvc@npm:1.6.3": "@swc/core-win32-arm64-msvc@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-win32-arm64-msvc@npm:1.6.3" resolution: "@swc/core-win32-arm64-msvc@npm:1.9.2"
conditions: os=win32 & cpu=arm64 conditions: os=win32 & cpu=arm64
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-win32-ia32-msvc@npm:1.6.3": "@swc/core-win32-ia32-msvc@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-win32-ia32-msvc@npm:1.6.3" resolution: "@swc/core-win32-ia32-msvc@npm:1.9.2"
conditions: os=win32 & cpu=ia32 conditions: os=win32 & cpu=ia32
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-win32-x64-msvc@npm:1.6.3": "@swc/core-win32-x64-msvc@npm:1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core-win32-x64-msvc@npm:1.6.3" resolution: "@swc/core-win32-x64-msvc@npm:1.9.2"
conditions: os=win32 & cpu=x64 conditions: os=win32 & cpu=x64
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core@npm:^1.6.3": "@swc/core@npm:^1.9.2":
version: 1.6.3 version: 1.9.2
resolution: "@swc/core@npm:1.6.3" resolution: "@swc/core@npm:1.9.2"
dependencies: dependencies:
"@swc/core-darwin-arm64": "npm:1.6.3" "@swc/core-darwin-arm64": "npm:1.9.2"
"@swc/core-darwin-x64": "npm:1.6.3" "@swc/core-darwin-x64": "npm:1.9.2"
"@swc/core-linux-arm-gnueabihf": "npm:1.6.3" "@swc/core-linux-arm-gnueabihf": "npm:1.9.2"
"@swc/core-linux-arm64-gnu": "npm:1.6.3" "@swc/core-linux-arm64-gnu": "npm:1.9.2"
"@swc/core-linux-arm64-musl": "npm:1.6.3" "@swc/core-linux-arm64-musl": "npm:1.9.2"
"@swc/core-linux-x64-gnu": "npm:1.6.3" "@swc/core-linux-x64-gnu": "npm:1.9.2"
"@swc/core-linux-x64-musl": "npm:1.6.3" "@swc/core-linux-x64-musl": "npm:1.9.2"
"@swc/core-win32-arm64-msvc": "npm:1.6.3" "@swc/core-win32-arm64-msvc": "npm:1.9.2"
"@swc/core-win32-ia32-msvc": "npm:1.6.3" "@swc/core-win32-ia32-msvc": "npm:1.9.2"
"@swc/core-win32-x64-msvc": "npm:1.6.3" "@swc/core-win32-x64-msvc": "npm:1.9.2"
"@swc/counter": "npm:^0.1.3" "@swc/counter": "npm:^0.1.3"
"@swc/types": "npm:^0.1.8" "@swc/types": "npm:^0.1.15"
peerDependencies: peerDependencies:
"@swc/helpers": "*" "@swc/helpers": "*"
dependenciesMeta: dependenciesMeta:
@@ -288,7 +290,7 @@ __metadata:
peerDependenciesMeta: peerDependenciesMeta:
"@swc/helpers": "@swc/helpers":
optional: true optional: true
checksum: b4c84a083ecabb0280ba53dffa65a5a575321de94081ad52bd12027fe3b5c8957978f2211b6036e2e28d904dd046fca238106c2106b32d02b752808a51193d35 checksum: 6793f2014a016f90b1c41a695f6d3a14d574e129e78f651fe3d6dbacbc6d0836ab7a7eb445d873a302b060b25ae34c4e09d0f94574a71da47c6424c5fa58aa10
languageName: node languageName: node
linkType: hard linkType: hard
@@ -299,12 +301,12 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/types@npm:^0.1.8": "@swc/types@npm:^0.1.15":
version: 0.1.8 version: 0.1.15
resolution: "@swc/types@npm:0.1.8" resolution: "@swc/types@npm:0.1.15"
dependencies: dependencies:
"@swc/counter": "npm:^0.1.3" "@swc/counter": "npm:^0.1.3"
checksum: 2d1cda35116e03714137c1c37f4493efe0e26e88285ecc9dcdf6256a77984e367ea7b5f31d650f110fdcfd6ac53dff3ec77f841787ca328d2efa7b07ef1ac318 checksum: d8bf063aeebac51290d1edf0cec52e2e5b5afced0dc6933510a86947e10f0f77976bc14c3efb5e8f265a9cbdeb0929e00e44b2f82c6d0f273997c5029417b769
languageName: node languageName: node
linkType: hard linkType: hard
@@ -361,12 +363,12 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@types/node@npm:^20.14.6": "@types/node@npm:^22.9.0":
version: 20.14.6 version: 22.9.0
resolution: "@types/node@npm:20.14.6" resolution: "@types/node@npm:22.9.0"
dependencies: dependencies:
undici-types: "npm:~5.26.4" undici-types: "npm:~6.19.8"
checksum: 1dcfeeb03ce3c3a1d8a537fefee7cd0cffb78f89e9535b74ee12940559566b57c39dad20d1b165b60b5727408dd44e1a52e5c01cf02d0a99d93ef3da8062c86e checksum: a7df3426891868b0f5fb03e46aeddd8446178233521c624a44531c92a040cf08a82d8235f7e1e02af731fd16984665d4d71f3418caf9c2788313b10f040d615d
languageName: node languageName: node
linkType: hard linkType: hard
@@ -628,13 +630,13 @@ __metadata:
version: 0.0.0-use.local version: 0.0.0-use.local
resolution: "dd-minimal-bot@workspace:." resolution: "dd-minimal-bot@workspace:."
dependencies: dependencies:
"@discordeno/bot": "npm:19.0.0-next.92bf166" "@discordeno/bot": "npm:19.0.0"
"@swc/cli": "npm:^0.3.12" "@swc/cli": "npm:^0.5.0"
"@swc/core": "npm:^1.6.3" "@swc/core": "npm:^1.9.2"
"@types/node": "npm:^20.14.6" "@types/node": "npm:^22.9.0"
chalk: "npm:^5.3.0" chalk: "npm:^5.3.0"
dotenv: "npm:^16.4.5" dotenv: "npm:^16.4.5"
typescript: "npm:^5.5.2" typescript: "npm:^5.6.3"
languageName: unknown languageName: unknown
linkType: soft linkType: soft
@@ -897,6 +899,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"fzstd@npm:^0.1.1":
version: 0.1.1
resolution: "fzstd@npm:0.1.1"
checksum: 455b968aeb764f06d9c39a5c8b45eefd645f7ee9129896e890eafb8ab367482f8495de12907021a32f6544494305a42a2056c30c63efac06181e6efcdab3fe78
languageName: node
linkType: hard
"get-stream@npm:^3.0.0": "get-stream@npm:^3.0.0":
version: 3.0.0 version: 3.0.0
resolution: "get-stream@npm:3.0.0" resolution: "get-stream@npm:3.0.0"
@@ -1972,30 +1981,23 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"tweetnacl@npm:^1.0.3": "typescript@npm:^5.6.3":
version: 1.0.3 version: 5.6.3
resolution: "tweetnacl@npm:1.0.3" resolution: "typescript@npm:5.6.3"
checksum: ca122c2f86631f3c0f6d28efb44af2a301d4a557a62a3e2460286b08e97567b258c2212e4ad1cfa22bd6a57edcdc54ba76ebe946847450ab0999e6d48ccae332
languageName: node
linkType: hard
"typescript@npm:^5.5.2":
version: 5.5.2
resolution: "typescript@npm:5.5.2"
bin: bin:
tsc: bin/tsc tsc: bin/tsc
tsserver: bin/tsserver tsserver: bin/tsserver
checksum: 9118b20f248e76b0dbff8737fef65dfa89d02668d4e633d2c5ceac99033a0ca5e8a1c1a53bc94da68e8f67677a88f318663dde859c9e9a09c1e116415daec2ba checksum: c328e418e124b500908781d9f7b9b93cf08b66bf5936d94332b463822eea2f4e62973bfb3b8a745fdc038785cb66cf59d1092bac3ec2ac6a3e5854687f7833f1
languageName: node languageName: node
linkType: hard linkType: hard
"typescript@patch:typescript@npm%3A^5.5.2#optional!builtin<compat/typescript>": "typescript@patch:typescript@npm%3A^5.6.3#optional!builtin<compat/typescript>":
version: 5.5.2 version: 5.6.3
resolution: "typescript@patch:typescript@npm%3A5.5.2#optional!builtin<compat/typescript>::version=5.5.2&hash=e012d7" resolution: "typescript@patch:typescript@npm%3A5.6.3#optional!builtin<compat/typescript>::version=5.6.3&hash=e012d7"
bin: bin:
tsc: bin/tsc tsc: bin/tsc
tsserver: bin/tsserver tsserver: bin/tsserver
checksum: 28b3de2ddaf63a7620e7ddbe5d377af71ce93ecc558c41bf0e3d88661d8e6e7aa6c7739164fef98055f69819e41faca49252938ef3633a3dff2734cca6a9042e checksum: dc4bec403cd33a204b655b1152a096a08e7bad2c931cb59ef8ff26b6f2aa541bf98f09fc157958a60c921b1983a8dde9a85b692f9de60fa8f574fd131e3ae4dd
languageName: node languageName: node
linkType: hard linkType: hard
@@ -2006,6 +2008,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"undici-types@npm:~6.19.8":
version: 6.19.8
resolution: "undici-types@npm:6.19.8"
checksum: cf0b48ed4fc99baf56584afa91aaffa5010c268b8842f62e02f752df209e3dea138b372a60a963b3b2576ed932f32329ce7ddb9cb5f27a6c83040d8cd74b7a70
languageName: node
linkType: hard
"unique-filename@npm:^3.0.0": "unique-filename@npm:^3.0.0":
version: 3.0.0 version: 3.0.0
resolution: "unique-filename@npm:3.0.0" resolution: "unique-filename@npm:3.0.0"
@@ -2093,7 +2102,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"ws@npm:^8.16.0": "ws@npm:^8.18.0":
version: 8.18.0 version: 8.18.0
resolution: "ws@npm:8.18.0" resolution: "ws@npm:8.18.0"
peerDependencies: peerDependencies:
+1
View File
@@ -10,5 +10,6 @@ Example bot for reaction-roles using Discord Interactions and not classic reacti
## Run the bot ## Run the bot
1. `yarn` to install the dependencies 1. `yarn` to install the dependencies
1. `yarn postinstall` to run the Discordeno Desired Properties CLI
1. `yarn build` to build the .ts files into .js 1. `yarn build` to build the .ts files into .js
1. `yarn start` (or `node ./dist/index.js`) to run the bot 1. `yarn start` (or `node ./dist/index.js`) to run the bot
+5 -5
View File
@@ -12,13 +12,13 @@
"setup-dd": "" "setup-dd": ""
}, },
"dependencies": { "dependencies": {
"@discordeno/bot": "19.0.0-next.ad7e74c", "@discordeno/bot": "19.0.0",
"dotenv": "^16.4.5" "dotenv": "^16.4.5"
}, },
"devDependencies": { "devDependencies": {
"@swc/cli": "^0.3.12", "@swc/cli": "^0.5.0",
"@swc/core": "^1.5.25", "@swc/core": "^1.9.2",
"@types/node": "^20.14.2", "@types/node": "^22.9.0",
"typescript": "^5.4.5" "typescript": "^5.6.3"
} }
} }
+47
View File
@@ -0,0 +1,47 @@
import { createBot } from '@discordeno/bot'
import events from './events/index.js'
import { config } from 'dotenv'
config()
const token = process.env.TOKEN
// Ensure the existence of the TOKEN env
if (!token) throw new Error('The TOKEN environment variable needs to be defined.')
export const bot = createBot({
token,
desiredProperties: {
user: {
id: true,
},
message: {
id: true,
},
member: {
roles: true,
},
interaction: {
id: true,
data: true,
type: true,
user: true,
token: true,
member: true,
message: true,
guildId: true,
channelId: true,
},
interactionCallbackResponse: {
resource: true,
},
interactionResource: {
message: true,
},
role: {
id: true,
},
},
})
bot.events = events
@@ -1,5 +1,5 @@
import type { Interaction } from '@discordeno/bot'
import type { CreateSlashApplicationCommand } from '@discordeno/types' import type { CreateSlashApplicationCommand } from '@discordeno/types'
import type { bot } from '../bot.js'
import roles from './roles.js' import roles from './roles.js'
export const commands = new Map<string, Command>([roles].map((cmd) => [cmd.name, cmd])) export const commands = new Map<string, Command>([roles].map((cmd) => [cmd.name, cmd]))
@@ -8,5 +8,5 @@ export default commands
export interface Command extends CreateSlashApplicationCommand { export interface Command extends CreateSlashApplicationCommand {
/** Handler that will be executed when this command is triggered */ /** Handler that will be executed when this command is triggered */
execute: (interaction: Interaction, args: Record<string, unknown>) => Promise<unknown> execute: (interaction: typeof bot.transformers.$inferredTypes.interaction, args: Record<string, unknown>) => Promise<unknown>
} }
@@ -1,17 +1,16 @@
import assert from 'node:assert'
import { import {
type ActionRow, type ActionRow,
type ButtonComponent, type ButtonComponent,
DiscordInteractionContextType, DiscordInteractionContextType,
type Interaction,
MessageComponentTypes, MessageComponentTypes,
type Role,
type SelectMenuComponent, type SelectMenuComponent,
TextStyles, TextStyles,
} from '@discordeno/bot' } from '@discordeno/bot'
import { ApplicationCommandOptionTypes, ButtonStyles } from '@discordeno/types' import { ApplicationCommandOptionTypes, ButtonStyles } from '@discordeno/types'
import { bot } from '../bot.js'
import ItemCollector from '../collector.js' import ItemCollector from '../collector.js'
import { collectors } from '../events/interactionCreate.js' import { collectors } from '../events/interactionCreate.js'
import { bot } from '../index.js'
import type { Command } from './index.js' import type { Command } from './index.js'
const command: Command = { const command: Command = {
@@ -91,13 +90,12 @@ const command: Command = {
// NOTE: we use a copy so when we edit this actionRow the edits don't get applied to all the command executions, only this one, for example we do disable some buttons in some conditional cases // NOTE: we use a copy so when we edit this actionRow the edits don't get applied to all the command executions, only this one, for example we do disable some buttons in some conditional cases
const messageActionRow = structuredClone(messageActionRowTemplate) const messageActionRow = structuredClone(messageActionRowTemplate)
await interaction.defer(true)
const message = await interaction.respond( const message = await interaction.respond(
{ {
content: 'Use the buttons in this message to edit the message below.', content: 'Use the buttons in this message to edit the message below.',
components: [messageActionRow], components: [messageActionRow],
}, },
{ isPrivate: true }, { isPrivate: true, withResponse: true },
) )
if (!message) { if (!message) {
@@ -105,8 +103,10 @@ const command: Command = {
return return
} }
assert('resource' in message && message.resource?.message)
// Create the collector for the menu // Create the collector for the menu
const itemCollector = new ItemCollector<Interaction>() const itemCollector = new ItemCollector<typeof bot.transformers.$inferredTypes.interaction>()
collectors.add(itemCollector) collectors.add(itemCollector)
// For the new reaction role, we need to keep track of what the user gave us // For the new reaction role, we need to keep track of what the user gave us
@@ -114,7 +114,7 @@ const command: Command = {
itemCollector.onItem(async (i) => { itemCollector.onItem(async (i) => {
// We need to verify the interaction is for us. // We need to verify the interaction is for us.
if (i.message?.id !== message.id) { if (i.message?.id !== message.resource?.message?.id) {
return return
} }
@@ -314,7 +314,7 @@ export default command
interface CommandArgs { interface CommandArgs {
reactions?: { reactions?: {
create?: { create?: {
role: Role role: typeof bot.transformers.$inferredTypes.role
emoji: string emoji: string
color: ButtonStyles color: ButtonStyles
label?: string label?: string
@@ -432,7 +432,7 @@ const selectLabelActionRow: ActionRow = {
// Function to get all the actionRows with buttons for the reaction roles message // Function to get all the actionRows with buttons for the reaction roles message
function getRoleButtons( function getRoleButtons(
roles: Array<{ roles: Array<{
role: Role role: typeof bot.transformers.$inferredTypes.role
emoji: string emoji: string
color: ButtonStyles color: ButtonStyles
label?: string | undefined label?: string | undefined
+2 -2
View File
@@ -1,10 +1,10 @@
import type { EventHandlers } from '@discordeno/bot' import type { bot } from '../bot.js'
import { event as interactionCreateEvent } from './interactionCreate.js' import { event as interactionCreateEvent } from './interactionCreate.js'
import { event as readyEvent } from './ready.js' import { event as readyEvent } from './ready.js'
export const events = { export const events = {
interactionCreate: interactionCreateEvent, interactionCreate: interactionCreateEvent,
ready: readyEvent, ready: readyEvent,
} as Partial<EventHandlers> } as typeof bot.events
export default events export default events
@@ -1,10 +1,11 @@
import { type EventHandlers, type Interaction, InteractionTypes, MessageComponentTypes, commandOptionsParser } from '@discordeno/bot' import { InteractionTypes, MessageComponentTypes, commandOptionsParser } from '@discordeno/bot'
import { bot } from '../bot.js'
import type ItemCollector from '../collector.js' import type ItemCollector from '../collector.js'
import commands from '../commands/index.js' import commands from '../commands/index.js'
export const collectors = new Set<ItemCollector<Interaction>>() export const collectors = new Set<ItemCollector<typeof bot.transformers.$inferredTypes.interaction>>()
export const event: EventHandlers['interactionCreate'] = async (interaction) => { export const event: typeof bot.events.interactionCreate = async (interaction) => {
// Give to all the collectors the interaction to use // Give to all the collectors the interaction to use
for (const collector of collectors) { for (const collector of collectors) {
collector.collect(interaction) collector.collect(interaction)
@@ -18,6 +19,7 @@ export const event: EventHandlers['interactionCreate'] = async (interaction) =>
if (!command) return if (!command) return
try { try {
// @ts-expect-error commandOptionsParser is bugged at the moment, it wants an Interaction and not the desired props customized interaction
await command.execute(interaction, commandOptionsParser(interaction)) await command.execute(interaction, commandOptionsParser(interaction))
} catch (error) { } catch (error) {
console.error(error) console.error(error)
@@ -38,14 +40,14 @@ export const event: EventHandlers['interactionCreate'] = async (interaction) =>
try { try {
if (alreadyHasRole) { if (alreadyHasRole) {
await interaction.bot.helpers.removeRole(interaction.guildId, interaction.user.id, roleId, `Reaction role button for role id ${roleId}`) await bot.helpers.removeRole(interaction.guildId, interaction.user.id, roleId, `Reaction role button for role id ${roleId}`)
await interaction.respond(`I removed from you the <@&${roleId}> role.`, { isPrivate: true }) await interaction.respond(`I removed from you the <@&${roleId}> role.`, { isPrivate: true })
return return
} }
// You will get an invalid request made if the bot attempts to give a bot role, a role higher then him hightest role, a link role or if it does not have the Manage Roles permission // You will get an invalid request made if the bot attempts to give a bot role, a role higher then him hightest role, a link role or if it does not have the Manage Roles permission
// This could be prevented by checking for the roles that the bot owns and the role that the bot is trying to add // This could be prevented by checking for the roles that the bot owns and the role that the bot is trying to add
await interaction.bot.helpers.addRole(interaction.guildId, interaction.user.id, roleId, `Reaction role button for role id ${roleId}`) await bot.helpers.addRole(interaction.guildId, interaction.user.id, roleId, `Reaction role button for role id ${roleId}`)
await interaction.respond(`I added to you the <@&${roleId}> role.`, { isPrivate: true }) await interaction.respond(`I added to you the <@&${roleId}> role.`, { isPrivate: true })
} catch { } catch {
// Respond with an error message // Respond with an error message
+2 -3
View File
@@ -1,7 +1,6 @@
import type { EventHandlers } from '@discordeno/bot' import { bot } from '../bot.js'
import { bot } from '../index.js'
export const event: EventHandlers['ready'] = () => { export const event: typeof bot.events.ready = () => {
// Print to the console when the bot has connected to discord and is ready to handle the events // Print to the console when the bot has connected to discord and is ready to handle the events
bot.logger.info('The bot is ready!') bot.logger.info('The bot is ready!')
} }
+1 -35
View File
@@ -1,38 +1,4 @@
import { createBot } from '@discordeno/bot' import { bot } from './bot.js'
import { config } from 'dotenv'
import events from './events/index.js'
config()
const token = process.env.TOKEN
// Ensure the existence of the TOKEN env
if (!token) throw new Error('The TOKEN environment variable needs to be defined.')
export const bot = createBot({
token,
events,
})
// Setup for the desiredProperties
bot.transformers.desiredProperties.user.id = true
bot.transformers.desiredProperties.message.id = true
bot.transformers.desiredProperties.member.roles = true
bot.transformers.desiredProperties.interaction.id = true
bot.transformers.desiredProperties.interaction.data = true
bot.transformers.desiredProperties.interaction.type = true
bot.transformers.desiredProperties.interaction.user = true
bot.transformers.desiredProperties.interaction.token = true
bot.transformers.desiredProperties.interaction.member = true
bot.transformers.desiredProperties.interaction.message = true
bot.transformers.desiredProperties.interaction.guildId = true
bot.transformers.desiredProperties.interaction.channelId = true
bot.transformers.desiredProperties.role.id = true
await bot.start() await bot.start()
@@ -1,8 +1,14 @@
import { config } from 'dotenv'
config()
import { bot } from './bot.js'
import commands from './commands/index.js' import commands from './commands/index.js'
import { bot } from './index.js'
const guildId = 'REPLACE WITH YOUR GUILD ID' const guildId = 'REPLACE WITH YOUR GUILD ID'
await bot.rest await bot.rest
.upsertGuildApplicationCommands(guildId, [...commands.values()]) .upsertGuildApplicationCommands(guildId, [...commands.values()])
.catch((e) => bot.logger.error('There was an error when updating the global commands', e)) .catch((e) => bot.logger.error('There was an error when updating the global commands', e))
process.exit(0)
+120 -111
View File
@@ -5,54 +5,56 @@ __metadata:
version: 8 version: 8
cacheKey: 10 cacheKey: 10
"@discordeno/bot@npm:19.0.0-next.ad7e74c": "@discordeno/bot@npm:19.0.0":
version: 19.0.0-next.ad7e74c version: 19.0.0
resolution: "@discordeno/bot@npm:19.0.0-next.ad7e74c" resolution: "@discordeno/bot@npm:19.0.0"
dependencies: dependencies:
"@discordeno/gateway": "npm:19.0.0-next.ad7e74c" "@discordeno/gateway": "npm:19.0.0"
"@discordeno/rest": "npm:19.0.0-next.ad7e74c" "@discordeno/rest": "npm:19.0.0"
"@discordeno/types": "npm:19.0.0-next.ad7e74c" "@discordeno/types": "npm:19.0.0"
"@discordeno/utils": "npm:19.0.0-next.ad7e74c" "@discordeno/utils": "npm:19.0.0"
checksum: 0bbcd98f1bb42bde47d262a67fa7b42ff4f5ef8f4556ef3117b8204cb864c6f26c0066320374ede6cf0e9730988a5c0b12472108dcf0cbc45b951db305a0671c checksum: 86ac4cd61761c1b3c3fa82db08742dcdba18ffb1b6042455c8a5e8cdd02231543c3c2d43dfb29084d44034cafebdc6ab51969c5930281ab2be83d5b159b69726
languageName: node languageName: node
linkType: hard linkType: hard
"@discordeno/gateway@npm:19.0.0-next.ad7e74c": "@discordeno/gateway@npm:19.0.0":
version: 19.0.0-next.ad7e74c version: 19.0.0
resolution: "@discordeno/gateway@npm:19.0.0-next.ad7e74c" resolution: "@discordeno/gateway@npm:19.0.0"
dependencies: dependencies:
"@discordeno/types": "npm:19.0.0-next.ad7e74c" "@discordeno/types": "npm:19.0.0"
"@discordeno/utils": "npm:19.0.0-next.ad7e74c" "@discordeno/utils": "npm:19.0.0"
ws: "npm:^8.16.0" fzstd: "npm:^0.1.1"
checksum: b16676060574a3a45c2388f7c73e62d7763bfdb87d5f0f84f673b7f68f34d5085e3a300c9a15f4120b2909ba776ef78336025c71541f68c50729379458ac9273 ws: "npm:^8.18.0"
dependenciesMeta:
fzstd:
optional: true
checksum: 241ec9981bf47ff894990889477fbc1ce91361648534189361e9dca4d927aba15c941604da29ba135cb20871fac7e82e5cc1eed1df6ef3d86bbcdfdca3448649
languageName: node languageName: node
linkType: hard linkType: hard
"@discordeno/rest@npm:19.0.0-next.ad7e74c": "@discordeno/rest@npm:19.0.0":
version: 19.0.0-next.ad7e74c version: 19.0.0
resolution: "@discordeno/rest@npm:19.0.0-next.ad7e74c" resolution: "@discordeno/rest@npm:19.0.0"
dependencies: dependencies:
"@discordeno/types": "npm:19.0.0-next.ad7e74c" "@discordeno/types": "npm:19.0.0"
"@discordeno/utils": "npm:19.0.0-next.ad7e74c" "@discordeno/utils": "npm:19.0.0"
dotenv: "npm:^16.4.5" checksum: e1ce6c092566e58c5d407a5fee7c6c38f988251abcbaaf14beaa084691b4c52dc4f6c54f46974735090fafe174b1914374edd074bffd441e11d76851575a136f
checksum: d0fd00393b5845c17c862e9d8ce5197363d60db3073136b9b6f19b1fa5a20ea3020f180e627140f8e12a6cab65f736e3bbad1b376d959e49341efa81e43c65b8
languageName: node languageName: node
linkType: hard linkType: hard
"@discordeno/types@npm:19.0.0-next.ad7e74c": "@discordeno/types@npm:19.0.0":
version: 19.0.0-next.ad7e74c version: 19.0.0
resolution: "@discordeno/types@npm:19.0.0-next.ad7e74c" resolution: "@discordeno/types@npm:19.0.0"
checksum: 3981908e1f88c22821a6abdc2056791a6dc75d09b9bc6ee96a1689871330745574c8824c314cf200b7df16d48215dc9b00e41f2fff03db26102c54422a82ab88 checksum: aaf832d6510b7aa0ead75bd5c1d1990f3a77fa980d40122d6d092abc571280aed6864b10fdda705d70bd7ba73961f4b3a0ee28c6b7cabb09595574f65fcfd61c
languageName: node languageName: node
linkType: hard linkType: hard
"@discordeno/utils@npm:19.0.0-next.ad7e74c": "@discordeno/utils@npm:19.0.0":
version: 19.0.0-next.ad7e74c version: 19.0.0
resolution: "@discordeno/utils@npm:19.0.0-next.ad7e74c" resolution: "@discordeno/utils@npm:19.0.0"
dependencies: dependencies:
"@discordeno/types": "npm:19.0.0-next.ad7e74c" "@discordeno/types": "npm:19.0.0"
tweetnacl: "npm:^1.0.3" checksum: b2d430099672cfb8b68d6a9bd12803cd69cb909dc1f368d8305a4bb1067499babff05997a29599b51029d0add435bea4a03929140abf77dd83e1741baaa37855
checksum: 3b9265737208db205732e5f442d82c10a27952359a98ffb2f8835a4c94d43520d0490ab488faec68f40bd3205a42f4877804397eade83ada658a00e854270dc7
languageName: node languageName: node
linkType: hard linkType: hard
@@ -149,9 +151,9 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/cli@npm:^0.3.12": "@swc/cli@npm:^0.5.0":
version: 0.3.12 version: 0.5.0
resolution: "@swc/cli@npm:0.3.12" resolution: "@swc/cli@npm:0.5.0"
dependencies: dependencies:
"@mole-inc/bin-wrapper": "npm:^8.0.1" "@mole-inc/bin-wrapper": "npm:^8.0.1"
"@swc/counter": "npm:^0.1.3" "@swc/counter": "npm:^0.1.3"
@@ -172,96 +174,96 @@ __metadata:
spack: bin/spack.js spack: bin/spack.js
swc: bin/swc.js swc: bin/swc.js
swcx: bin/swcx.js swcx: bin/swcx.js
checksum: fee260434fad8eed0328f4db17f42ce0864b93b90fcb02f3f0eb3aad994b5a6ae4bfdfb6d2329377e0cd8d07adc61cca42e290bf0005c1ab4d004d4a0b152db4 checksum: 033b682f1c25c8fae731414d2a463a0e455452bf9349c025cd88ea63ee1e5a589032eb206063fd925daf12065c9f1e5b4680cef50cc24674681c4d2583b7dca0
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-darwin-arm64@npm:1.5.25": "@swc/core-darwin-arm64@npm:1.9.2":
version: 1.5.25 version: 1.9.2
resolution: "@swc/core-darwin-arm64@npm:1.5.25" resolution: "@swc/core-darwin-arm64@npm:1.9.2"
conditions: os=darwin & cpu=arm64 conditions: os=darwin & cpu=arm64
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-darwin-x64@npm:1.5.25": "@swc/core-darwin-x64@npm:1.9.2":
version: 1.5.25 version: 1.9.2
resolution: "@swc/core-darwin-x64@npm:1.5.25" resolution: "@swc/core-darwin-x64@npm:1.9.2"
conditions: os=darwin & cpu=x64 conditions: os=darwin & cpu=x64
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-linux-arm-gnueabihf@npm:1.5.25": "@swc/core-linux-arm-gnueabihf@npm:1.9.2":
version: 1.5.25 version: 1.9.2
resolution: "@swc/core-linux-arm-gnueabihf@npm:1.5.25" resolution: "@swc/core-linux-arm-gnueabihf@npm:1.9.2"
conditions: os=linux & cpu=arm conditions: os=linux & cpu=arm
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-linux-arm64-gnu@npm:1.5.25": "@swc/core-linux-arm64-gnu@npm:1.9.2":
version: 1.5.25 version: 1.9.2
resolution: "@swc/core-linux-arm64-gnu@npm:1.5.25" resolution: "@swc/core-linux-arm64-gnu@npm:1.9.2"
conditions: os=linux & cpu=arm64 & libc=glibc conditions: os=linux & cpu=arm64 & libc=glibc
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-linux-arm64-musl@npm:1.5.25": "@swc/core-linux-arm64-musl@npm:1.9.2":
version: 1.5.25 version: 1.9.2
resolution: "@swc/core-linux-arm64-musl@npm:1.5.25" resolution: "@swc/core-linux-arm64-musl@npm:1.9.2"
conditions: os=linux & cpu=arm64 & libc=musl conditions: os=linux & cpu=arm64 & libc=musl
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-linux-x64-gnu@npm:1.5.25": "@swc/core-linux-x64-gnu@npm:1.9.2":
version: 1.5.25 version: 1.9.2
resolution: "@swc/core-linux-x64-gnu@npm:1.5.25" resolution: "@swc/core-linux-x64-gnu@npm:1.9.2"
conditions: os=linux & cpu=x64 & libc=glibc conditions: os=linux & cpu=x64 & libc=glibc
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-linux-x64-musl@npm:1.5.25": "@swc/core-linux-x64-musl@npm:1.9.2":
version: 1.5.25 version: 1.9.2
resolution: "@swc/core-linux-x64-musl@npm:1.5.25" resolution: "@swc/core-linux-x64-musl@npm:1.9.2"
conditions: os=linux & cpu=x64 & libc=musl conditions: os=linux & cpu=x64 & libc=musl
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-win32-arm64-msvc@npm:1.5.25": "@swc/core-win32-arm64-msvc@npm:1.9.2":
version: 1.5.25 version: 1.9.2
resolution: "@swc/core-win32-arm64-msvc@npm:1.5.25" resolution: "@swc/core-win32-arm64-msvc@npm:1.9.2"
conditions: os=win32 & cpu=arm64 conditions: os=win32 & cpu=arm64
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-win32-ia32-msvc@npm:1.5.25": "@swc/core-win32-ia32-msvc@npm:1.9.2":
version: 1.5.25 version: 1.9.2
resolution: "@swc/core-win32-ia32-msvc@npm:1.5.25" resolution: "@swc/core-win32-ia32-msvc@npm:1.9.2"
conditions: os=win32 & cpu=ia32 conditions: os=win32 & cpu=ia32
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core-win32-x64-msvc@npm:1.5.25": "@swc/core-win32-x64-msvc@npm:1.9.2":
version: 1.5.25 version: 1.9.2
resolution: "@swc/core-win32-x64-msvc@npm:1.5.25" resolution: "@swc/core-win32-x64-msvc@npm:1.9.2"
conditions: os=win32 & cpu=x64 conditions: os=win32 & cpu=x64
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/core@npm:^1.5.25": "@swc/core@npm:^1.9.2":
version: 1.5.25 version: 1.9.2
resolution: "@swc/core@npm:1.5.25" resolution: "@swc/core@npm:1.9.2"
dependencies: dependencies:
"@swc/core-darwin-arm64": "npm:1.5.25" "@swc/core-darwin-arm64": "npm:1.9.2"
"@swc/core-darwin-x64": "npm:1.5.25" "@swc/core-darwin-x64": "npm:1.9.2"
"@swc/core-linux-arm-gnueabihf": "npm:1.5.25" "@swc/core-linux-arm-gnueabihf": "npm:1.9.2"
"@swc/core-linux-arm64-gnu": "npm:1.5.25" "@swc/core-linux-arm64-gnu": "npm:1.9.2"
"@swc/core-linux-arm64-musl": "npm:1.5.25" "@swc/core-linux-arm64-musl": "npm:1.9.2"
"@swc/core-linux-x64-gnu": "npm:1.5.25" "@swc/core-linux-x64-gnu": "npm:1.9.2"
"@swc/core-linux-x64-musl": "npm:1.5.25" "@swc/core-linux-x64-musl": "npm:1.9.2"
"@swc/core-win32-arm64-msvc": "npm:1.5.25" "@swc/core-win32-arm64-msvc": "npm:1.9.2"
"@swc/core-win32-ia32-msvc": "npm:1.5.25" "@swc/core-win32-ia32-msvc": "npm:1.9.2"
"@swc/core-win32-x64-msvc": "npm:1.5.25" "@swc/core-win32-x64-msvc": "npm:1.9.2"
"@swc/counter": "npm:^0.1.3" "@swc/counter": "npm:^0.1.3"
"@swc/types": "npm:^0.1.7" "@swc/types": "npm:^0.1.15"
peerDependencies: peerDependencies:
"@swc/helpers": "*" "@swc/helpers": "*"
dependenciesMeta: dependenciesMeta:
@@ -288,7 +290,7 @@ __metadata:
peerDependenciesMeta: peerDependenciesMeta:
"@swc/helpers": "@swc/helpers":
optional: true optional: true
checksum: 1ad878fe015d01c34ff20d8aee15b1cfb5cd66f9e8744e4be69e09628ade3c1108aa00c693da4eed6cc6ef08d686f6cab48a088ee61e933662eb8dd7b79d2e44 checksum: 6793f2014a016f90b1c41a695f6d3a14d574e129e78f651fe3d6dbacbc6d0836ab7a7eb445d873a302b060b25ae34c4e09d0f94574a71da47c6424c5fa58aa10
languageName: node languageName: node
linkType: hard linkType: hard
@@ -299,12 +301,12 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@swc/types@npm:^0.1.7": "@swc/types@npm:^0.1.15":
version: 0.1.7 version: 0.1.15
resolution: "@swc/types@npm:0.1.7" resolution: "@swc/types@npm:0.1.15"
dependencies: dependencies:
"@swc/counter": "npm:^0.1.3" "@swc/counter": "npm:^0.1.3"
checksum: ed66c26b36972a74f852c1781fadc75946578abfeeea58f110684833b5d1e70f28a77ddb82fd5bf3cf3c4dad0e1b6a1c924d7e2cc7a99f9b16ed16fe266bba25 checksum: d8bf063aeebac51290d1edf0cec52e2e5b5afced0dc6933510a86947e10f0f77976bc14c3efb5e8f265a9cbdeb0929e00e44b2f82c6d0f273997c5029417b769
languageName: node languageName: node
linkType: hard linkType: hard
@@ -361,12 +363,12 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@types/node@npm:^20.14.2": "@types/node@npm:^22.9.0":
version: 20.14.2 version: 22.9.0
resolution: "@types/node@npm:20.14.2" resolution: "@types/node@npm:22.9.0"
dependencies: dependencies:
undici-types: "npm:~5.26.4" undici-types: "npm:~6.19.8"
checksum: c38e47b190fa0a8bdfde24b036dddcf9401551f2fb170a90ff33625c7d6f218907e81c74e0fa6e394804a32623c24c60c50e249badc951007830f0d02c48ee0f checksum: a7df3426891868b0f5fb03e46aeddd8446178233521c624a44531c92a040cf08a82d8235f7e1e02af731fd16984665d4d71f3418caf9c2788313b10f040d615d
languageName: node languageName: node
linkType: hard linkType: hard
@@ -876,6 +878,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"fzstd@npm:^0.1.1":
version: 0.1.1
resolution: "fzstd@npm:0.1.1"
checksum: 455b968aeb764f06d9c39a5c8b45eefd645f7ee9129896e890eafb8ab367482f8495de12907021a32f6544494305a42a2056c30c63efac06181e6efcdab3fe78
languageName: node
linkType: hard
"get-stream@npm:^3.0.0": "get-stream@npm:^3.0.0":
version: 3.0.0 version: 3.0.0
resolution: "get-stream@npm:3.0.0" resolution: "get-stream@npm:3.0.0"
@@ -1604,12 +1613,12 @@ __metadata:
version: 0.0.0-use.local version: 0.0.0-use.local
resolution: "reaction-roles@workspace:." resolution: "reaction-roles@workspace:."
dependencies: dependencies:
"@discordeno/bot": "npm:19.0.0-next.ad7e74c" "@discordeno/bot": "npm:19.0.0"
"@swc/cli": "npm:^0.3.12" "@swc/cli": "npm:^0.5.0"
"@swc/core": "npm:^1.5.25" "@swc/core": "npm:^1.9.2"
"@types/node": "npm:^20.14.2" "@types/node": "npm:^22.9.0"
dotenv: "npm:^16.4.5" dotenv: "npm:^16.4.5"
typescript: "npm:^5.4.5" typescript: "npm:^5.6.3"
languageName: unknown languageName: unknown
linkType: soft linkType: soft
@@ -1950,30 +1959,23 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"tweetnacl@npm:^1.0.3": "typescript@npm:^5.6.3":
version: 1.0.3 version: 5.6.3
resolution: "tweetnacl@npm:1.0.3" resolution: "typescript@npm:5.6.3"
checksum: ca122c2f86631f3c0f6d28efb44af2a301d4a557a62a3e2460286b08e97567b258c2212e4ad1cfa22bd6a57edcdc54ba76ebe946847450ab0999e6d48ccae332
languageName: node
linkType: hard
"typescript@npm:^5.4.5":
version: 5.4.5
resolution: "typescript@npm:5.4.5"
bin: bin:
tsc: bin/tsc tsc: bin/tsc
tsserver: bin/tsserver tsserver: bin/tsserver
checksum: d04a9e27e6d83861f2126665aa8d84847e8ebabcea9125b9ebc30370b98cb38b5dff2508d74e2326a744938191a83a69aa9fddab41f193ffa43eabfdf3f190a5 checksum: c328e418e124b500908781d9f7b9b93cf08b66bf5936d94332b463822eea2f4e62973bfb3b8a745fdc038785cb66cf59d1092bac3ec2ac6a3e5854687f7833f1
languageName: node languageName: node
linkType: hard linkType: hard
"typescript@patch:typescript@npm%3A^5.4.5#optional!builtin<compat/typescript>": "typescript@patch:typescript@npm%3A^5.6.3#optional!builtin<compat/typescript>":
version: 5.4.5 version: 5.6.3
resolution: "typescript@patch:typescript@npm%3A5.4.5#optional!builtin<compat/typescript>::version=5.4.5&hash=e012d7" resolution: "typescript@patch:typescript@npm%3A5.6.3#optional!builtin<compat/typescript>::version=5.6.3&hash=e012d7"
bin: bin:
tsc: bin/tsc tsc: bin/tsc
tsserver: bin/tsserver tsserver: bin/tsserver
checksum: 584be8bac7112ad49a9eb9992f71d542b1ff2fafb5bb315e1c196145e8feab589f1d7223cfb2d5df6770789582e6918f8287d1f2f89911b38eb80e29c560ad00 checksum: dc4bec403cd33a204b655b1152a096a08e7bad2c931cb59ef8ff26b6f2aa541bf98f09fc157958a60c921b1983a8dde9a85b692f9de60fa8f574fd131e3ae4dd
languageName: node languageName: node
linkType: hard linkType: hard
@@ -1984,6 +1986,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"undici-types@npm:~6.19.8":
version: 6.19.8
resolution: "undici-types@npm:6.19.8"
checksum: cf0b48ed4fc99baf56584afa91aaffa5010c268b8842f62e02f752df209e3dea138b372a60a963b3b2576ed932f32329ce7ddb9cb5f27a6c83040d8cd74b7a70
languageName: node
linkType: hard
"unique-filename@npm:^3.0.0": "unique-filename@npm:^3.0.0":
version: 3.0.0 version: 3.0.0
resolution: "unique-filename@npm:3.0.0" resolution: "unique-filename@npm:3.0.0"
@@ -2071,7 +2080,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"ws@npm:^8.16.0": "ws@npm:^8.18.0":
version: 8.18.0 version: 8.18.0
resolution: "ws@npm:8.18.0" resolution: "ws@npm:8.18.0"
peerDependencies: peerDependencies:
+1 -1
View File
@@ -125,7 +125,7 @@ export interface CreateBotOptions<TProps extends RecursivePartial<TransformersDe
/** /**
* Set the desired properties behavior for undesired properties * Set the desired properties behavior for undesired properties
* *
* @default DesiredPropertiesBehavior.ChangeKey * @default DesiredPropertiesBehavior.RemoveKey
*/ */
desiredPropertiesBehavior?: TBehavior desiredPropertiesBehavior?: TBehavior
/** /**
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"label": "Beginner Tips", "label": "Beginner Tips",
"position": 4, "position": 5,
"link": { "link": {
"type": "generated-index", "type": "generated-index",
"description": "Guides for basic knowledge to use discordeno." "description": "Guides for basic knowledge to use discordeno."
+24 -42
View File
@@ -20,49 +20,30 @@ import { createBot } from '@discordeno/bot'
export const BOT = createBot({ export const BOT = createBot({
token, token,
events: {},
}) })
``` ```
Now that our bot manager is created, we need to implement our event handlers. First, we can make another file like `services/bot/events/index.ts` and paste the code below. Awesome, now we need to implement an event handler. For example, let's implement the ready event. So we make a file like `services/bot/events/ready.ts` and paste the code below:
```ts ```ts
import type { EventHandlers } from '@discordeno/bot' import { BOT } from '../bot.js'
export const events: Partial<EventHandlers> = { export const ready: typeof BOT.events.ready = async ({ shardId }) => {
// Fill this in the next section BOT.logger.info(`[READY] Shard ID #${shardId} is ready.`)
} }
``` ```
Now, we go back to the bot file and pass this events object to the createBot function. Now that we have a ready event handler, let's go ahead and add it to our bot.
```ts ```ts
import { createBot } from '@discordeno/bot' import { createBot } from '@discordeno/bot'
import { events } from './events/index.js' import { ready } from './events/ready.js'
export const BOT = createBot({ export const BOT = createBot({
token, token,
events,
}) })
```
Awesome, now the only thing left is we need to implement an event handler. For example, let's implement the ready event. So we make a file like `services/bot/events/ready.ts` and paste the code below: BOT.events.ready = ready;
```ts
export const ready: EventHandlers['ready'] = async function (payload, shardId) {
logger.info(`[READY] Shard ID #${shardId} is ready.`)
}
```
Now that we have a ready event handler, let's go ahead and add it to our events.
```ts
import type { EventHandlers } from '@discordeno/bot'
import { ready } from './ready.ts'
export const events: Partial<EventHandlers> = {
ready,
}
``` ```
There you go. You now have an event handler working perfectly. There you go. You now have an event handler working perfectly.
@@ -112,10 +93,12 @@ Now that we have the basic code setup complete for our listener, we can begin ad
```ts ```ts
try { try {
// OPTIONAL: Runs the raw event handler if you need it // Trigger the raw event, you may remove this if you don't need it
bot.events.raw(bot, req.body.payload, req.body.shardId); bot.events.raw?.(req.body.payload, req.body.shardId)
// Runs the event handler if available
if (message.t) bot.events.[snakeToCamelCase(message.t.toLowerCase())]?.(req.body.payload, req.body.shardId); if (data.t) {
bot.handlers[data.t]?.(bot, req.body.payload, req.body.shardId)
}
res.status(200).json({ success: true }) res.status(200).json({ success: true })
} }
@@ -128,15 +111,12 @@ Alright, now we need to start making our connection to the rest proxy work. That
```ts ```ts
export const BOT = createBot({ export const BOT = createBot({
token, token,
events, rest: {
}) proxy: {
baseUrl: process.env.REST_URL,
BOT.rest = createRestManager({ authorization: process.env.AUTHORIZATION,
token: process.env.TOKEN, },
proxy: { }
baseUrl: process.env.REST_URL,
authorization: process.env.AUTHORIZATION,
},
}) })
``` ```
@@ -192,9 +172,11 @@ Threading or workers or clusters, however you wish to call it can be used here.
With server splitting, we are going to split the amount of events that are handled by a bot process across several bot processes. So let's say we buy a couple servers for our bot processes. We can throw this process on both of them. Then go back to our `shards` in step 3 and make each shard send it to the appropriate server. If you think back, we already coded step 3 with this in mind. With server splitting, we are going to split the amount of events that are handled by a bot process across several bot processes. So let's say we buy a couple servers for our bot processes. We can throw this process on both of them. Then go back to our `shards` in step 3 and make each shard send it to the appropriate server. If you think back, we already coded step 3 with this in mind.
```ts ```ts
async message(shrd, payload) { async message(shard, payload) {
await fetch(getUrlFromShardId(req.body.totalShards, shrd.id), { await fetch(getUrlFromShardId(req.body.totalShards, shard.id), {
method: 'POST', method: 'POST',
})
}
``` ```
Here we were using a function to determine which url it should send to. Here we were using a function to determine which url it should send to.
+147
View File
@@ -0,0 +1,147 @@
---
sidebar_position: 4
sidebar_label: Desired Properties
---
# Desired Properties
The `desiredProperties` feature in Discordeno gives developers full control over memory utilization. This enables a highly lightweight setup, where only essential data is stored.
With `desiredProperties`, you can specify which properties to cache for each object type—such as users, members, channels, and guilds. This flexibility allows you to tailor caching to the exact needs of your bot, preserving only the data you truly require.
## Benefits
- **Memory Efficiency**: Only relevant data is stored, leading to substantial memory savings, especially for larger bots.
- **Improved Performance**: By storing minimal data, bots experience faster processing times and reduced resource usage.
- **Customizable**: Developers can enable specific properties on a per-object basis, eliminating unnecessary bloat.
## Example: The Memory Impact of Channel Topics
Consider the `channel.topic` property, which stores a text description for each channel.
While a single topic might not seem memory-intensive, this property can quickly become costly at scale:
- **Single Channel Topic**: A typical `channel.topic` can occupy hundreds of bytes.
- **Large Bot Scale**: If your bot operates across millions of servers with hundreds of millions of channels, storing every `channel.topic` would consume vast amounts of memory.
By choosing to store only the properties relevant to your bots functionality — like omitting `channel.topic` when its unnecessary — you can save gigabytes of memory.
Desired Properties is thus an essential tool for bots needing scalable and efficient caching, allowing for minimal resource usage without sacrificing performance.
:::tip
Check the [TypeScript](#typescript) section if you are using typescript
:::
## Configuring
To configure desired proprieties you can use the `desiredProperties` option on the `createBot` function
The objects inside `desiredProperties` contains all the names of the objects that have desired proprieties and in them you will find all the properties of the objects.
:::info[Flags and toggles]
Usually flags and toggles will be stored in a BitField to save on memory, Discordeno does provide getters on the objects for these flags however they aren't in desired properties with their individual names, instead you will find them as `toggles` and / or `flags` most of the cases.
:::
:::danger[NOT RECOMMENDED - Changing the default for Desired Properties]
You can change the default value for desired properties, using `desiredProprieties: createDesiredPropertiesObject({}, true) as CompleteDesiredProprieties<{}, true>` in the `createBot` function, however this will negate all the benefits desired proprieties provide.
The reason why this is not recommended is because while Desired Proprieties can be an annoyance at first, they have a significant performance impact on both CPU and memory usage.
Again, this is **NOT** RECOMMENDED, especially if you plan to ship your bot to production.
:::
### Computed values
Some values in these object may depend on some other value, notable examples are `user.bot` and `interaction.respond`. If you do not include all the values they depend on these require you might face undefined behavior using these values.
### Examples
In this example we will configure desired properties to have `user.id`, `user.bot` and `user.username`.
```ts
const bot = createBot({
// Your usual createBot options, such as token and intents
desiredProperties: {
user: {
id: true,
toggles: true, // Toggles includes the "bot" flag
username: true,
},
},
})
```
## TypeScript
Discordeno will give change the types of the supported objects to match your desired proprieties, for this reason you might get an error when incorrectly typing your functions.
Along side `desiredProperties` in the bot option that is explained above, `desiredPropertiesBehavior` is a configuration option for how should typescript threat proprieties that are not desired in your configuration.
Discordeno does expose the customized type according to your desired properties in the `bot.transformers.$inferredTypes` object, in these you will find all the types to be used in your functions / variables / ...
:::info
The value `bot.transformers.$inferredTypes` only exists for typescript. It will be `undefined` if tried to access at runtime, as it is not intended to provide any value at runtime, and it is intended to be used along side the `typeof` operator in typescript
:::
### Example
```ts
const bot = createBot({
// Your usual createBot options, such as token and intents
desiredProperties: {
message: {
id: true,
author: true,
}
user: {
id: true,
toggles: true, // Toggles includes the "bot" flag
username: true,
},
},
})
bot.events.messageCreate = (message) => {
processMessage(message)
}
function processMessage(message: typeof bot.transformers.$inferredTypes.message) {
bot.logger.info(`Message with id ${message.id} has author @${message.author.username}, whose has id ${message.author.id} and ${message.author.bot ? 'is' : "isn't"} a bot`)
// Do some other work with the message
}
```
### Configuring
There are 2 behaviors, `ChangeType` and `RemoveKey`. The default behavior is `RemoveKey`.
An example where the behavior is changed to `ChangeType` is:
```ts
const bot = createBot({
// Your usual createBot options, such as token and intents
desiredPropertiesBehavior: DesiredPropertiesBehavior.ChangeType,
desiredProperties: {
user: {
id: true,
toggles: true, // Toggles includes the "bot" flag
username: true,
},
},
})
```
Following is the explanation of each behavior:
#### `RemoveKey`
All the "undesired" properties will be removed from the type of the object. This will prevent you from using them at all since they "don't exist anymore".
The caveats of this behavior are the following:
- You don't know all the properties available on the object
- If a value requires other values to be enabled you won't know them without searching it up (when a computed value is missing a dependency it won't be shown)
#### `ChangeType`
All the "undesired" properties will be typed with a string that will explain why the property is disabled, this may also include the dependencies for said property if those are present.
The caveats of this behavior are the following:
- Typescript may not always error on the usage of undesired proprieties as in some context the string will be a valid option
+1 -1
View File
@@ -20,7 +20,7 @@ This is how you can use it to create a bot that logs into discord:
```ts ```ts
import { load } from 'https://deno.land/std@0.212.0/dotenv/mod.ts' import { load } from 'https://deno.land/std@0.212.0/dotenv/mod.ts'
import { createBot } from 'npm:@discordeno/bot@19.0.0-next.d81b28a' import { createBot } from 'npm:@discordeno/bot@19.0.0'
const env = await load() const env = await load()
+103 -91
View File
@@ -26,9 +26,8 @@ import { createBot } from '@discordeno/bot'
import { config } from 'dotenv' import { config } from 'dotenv'
config() config()
const bot = createBot({ export const bot = createBot({
token: process.env.TOKEN, token: process.env.TOKEN,
events: {},
}) })
await bot.start() await bot.start()
@@ -380,11 +379,10 @@ We need to parse all the options Discord has provided us. In the `/roles reactio
```ts ```ts
import commands from '../commands/index.js' import commands from '../commands/index.js'
import { bot } from '../bot.js'
import { commandOptionsParser } from '@discordeno/bot' import { commandOptionsParser } from '@discordeno/bot'
export const event: EventHandlers['interactionCreate'] = async function ( export const event: typeof bot.events.interactionCreate = async (interaction) => {
interaction,
) {
if (interaction.type === InteractionTypes.ApplicationCommand) { if (interaction.type === InteractionTypes.ApplicationCommand) {
if (!interaction.data) return if (!interaction.data) return
@@ -399,12 +397,12 @@ export const event: EventHandlers['interactionCreate'] = async function (
Now we need to create the `src/events/index.ts` file to collect all of our events and give it to the bot object. Now we need to create the `src/events/index.ts` file to collect all of our events and give it to the bot object.
```ts ```ts
import type { EventHandlers } from '@discordeno/bot' import type { bot } from '../bot.js'
import { event as interactionCreateEvent } from './interactionCreate.js' import { event as interactionCreateEvent } from './interactionCreate.js'
export const events = { export const events = {
interactionCreate: interactionCreateEvent, interactionCreate: interactionCreateEvent,
} as Partial<EventHandlers> } as typeof bot.events
export default events export default events
``` ```
@@ -416,20 +414,18 @@ To tell Discordeno to run the events, we need another change. Go back to the `sr
```ts ```ts
import { createBot } from '@discordeno/bot' import { createBot } from '@discordeno/bot'
import { config } from 'dotenv' import { config } from 'dotenv'
// insert-next-line
import events from './events/index.js' import events from './events/index.js'
config() config()
const bot = createBot({ export const bot = createBot({
token: process.env.TOKEN, token: process.env.TOKEN,
// remove-next-line
events: {},
// in this line we only use `events` but for javascript this will traduce to `events: events`
// insert-next-line
events,
}) })
// insert-next-line
bot.events = events
// ... REST OF THE FILE ... // ... REST OF THE FILE ...
``` ```
@@ -607,48 +603,36 @@ This also applies to the `interaction.respond` function that we call. It too has
If you save and then run the bot, you might noticed that Discord still says that the application did not respond, but how is that possibile? If you save and then run the bot, you might noticed that Discord still says that the application did not respond, but how is that possibile?
Although we just added the code to respond to the interaction, we have forgot a Discordeno concept called `desired properties`. This is an optimization Discordeno uses to make your code more performant but can be found annoying or unnecessary. Although we just added the code to respond to the interaction, we have forgot a Discordeno concept called `desired properties`. This is an optimization Discordeno uses to make your code more performant however it requires you do write some code. You can learn more on the [desired properties page](../desired-properties.md).
To explain how the `desired properties` work we need to talk about how Discord sends us data. Discord uses its own way to require/give data to who consumes the API. This guide won't go deep into this, but if you are interested can refer to the official documentation.
The way Discord sends us data is not the way that we (might) want it and for that reason Discordeno needs to map it from the Discord format to the Discordeno format. This is done via `transformers` defined in the `bot.transformers` object to tell Discordeno what we need from the pile of data Discord provides us.
Looking through the code we have written so far we can see that Looking through the code we have written so far we can see that
- We use `interaction.type` and `interaction.data` in the `src/events/interactionCreate.ts` file. - We use `interaction.type` and `interaction.data` in the `src/events/interactionCreate.ts` file.
- We use `interaction.channelId`, `interaction.id`, `interaction.token`, and `role.id` in our command. - We use `interaction.channelId`, `interaction.id`, `interaction.token`, and `role.id` in our command.
We need to add all of properties that we use to the `desired properties` list, and to do so we go back to `src/index.ts` and add a few lines: We need to add all of properties that we use to the `desiredProperties` list, and to do so we go back to `src/index.ts` and add a few lines:
```ts ```ts
// REST OF YOUR CODE // REST OF YOUR CODE
const bot = createBot({ export const bot = createBot({
token, token,
events, // insert-start
desiredProperties: {
interaction: {
id: true,
data: true,
type: true,
token: true,
channelId: true,
}
}
// insert-end
}) })
// insert-start
bot.transformers.desiredProperties.interaction.id = true
bot.transformers.desiredProperties.interaction.data = true
bot.transformers.desiredProperties.interaction.type = true
bot.transformers.desiredProperties.interaction.token = true
bot.transformers.desiredProperties.interaction.channelId = true
bot.transformers.desiredProperties.role.id = true
// insert-end
// REST OF YOUR CODE // REST OF YOUR CODE
``` ```
:::tip
As said before the code you are creating is your code, and in being so you can structure it how you find it better for you. This means that if you don't like having to specify the `bot.transformers.desiredProperties` lines in your index.ts nothing is preventing you from moving them somewhere else and make your code call them in a way or another, a way is for example moving to a file apart and creating a function that will edit all the values.
:::
:::note
If you want, you can disable the `desired properties` with the `defaultDesiredPropertiesValue` option in the createBot object, it isn't recommended but it's there to allow the developer to choose, keep in mind this will give you a warning in the console when you run the bot and memory/cpu usage WILL be higher.
:::
If we try again now we'll finally see our message with 3 buttons. But if we click any of the buttons, they don't do anything! This is expected, since we did not write any code to handle buttons. So let's talk about how to react to users' interactions beyond just commands If we try again now we'll finally see our message with 3 buttons. But if we click any of the buttons, they don't do anything! This is expected, since we did not write any code to handle buttons. So let's talk about how to react to users' interactions beyond just commands
### Handling interaction beyond commands ### Handling interaction beyond commands
@@ -698,7 +682,7 @@ import ItemCollector from '../collector.js'
// insert-next-line // insert-next-line
export const collectors = new Set<ItemCollector>() export const collectors = new Set<ItemCollector>()
export const event: EventHandlers['interactionCreate'] = async interaction => { export const event: typeof bot.event.interactionCreate = async interaction => {
// insert-next-line // insert-next-line
for (const collector of collectors) { for (const collector of collectors) {
// insert-next-line // insert-next-line
@@ -712,10 +696,6 @@ export const event: EventHandlers['interactionCreate'] = async interaction => {
In here you are defining a `Set` (for what we use, we can see it exactly the same as an array with a few helpful methods) of these collectors and when we receive an interaction from Discord we collect in all the collectors that have been added to then handle the interaction, so if the have just received the button click interaction we will now able to respond to it. In here you are defining a `Set` (for what we use, we can see it exactly the same as an array with a few helpful methods) of these collectors and when we receive an interaction from Discord we collect in all the collectors that have been added to then handle the interaction, so if the have just received the button click interaction we will now able to respond to it.
:::tip
As already said: you don't like how the collection is done in this example? You are free to change it and have fun in experimenting what you find to be the better way
:::
To do this we need to update the command, `src/events/roles.ts`: To do this we need to update the command, `src/events/roles.ts`:
```ts ```ts
@@ -777,16 +757,25 @@ You might remember from before that we discussed the desired properties, and we
```ts ```ts
// REST OF YOUR CODE // REST OF YOUR CODE
// insert-next-line export const bot = createBot({
bot.transformers.desiredProperties.message.id = true token,
desiredProperties: {
bot.transformers.desiredProperties.interaction.id = true interaction: {
bot.transformers.desiredProperties.interaction.data = true id: true,
bot.transformers.desiredProperties.interaction.type = true data: true,
bot.transformers.desiredProperties.interaction.token = true type: true,
// insert-next-line token: true,
bot.transformers.desiredProperties.interaction.message = true // insert-next-line
bot.transformers.desiredProperties.interaction.channelId = true message: true,
channelId: true,
},
// insert-start
message: {
id: true,
}
// insert-end
}
})
// REST OF YOUR CODE // REST OF YOUR CODE
``` ```
@@ -1382,23 +1371,34 @@ In this final piece of code, we use some desired properties. Let's go to the `sr
```ts ```ts
// REST OF YOUR CODE // REST OF YOUR CODE
// insert-next-line export const bot = createBot({
bot.transformers.desiredProperties.user.id = true token,
desiredProperties: {
bot.transformers.desiredProperties.message.id = true interaction: {
id: true,
bot.transformers.desiredProperties.interaction.id = true data: true,
bot.transformers.desiredProperties.interaction.data = true type: true,
bot.transformers.desiredProperties.interaction.type = true // insert-next-line
// insert-next-line user: true,
bot.transformers.desiredProperties.interaction.user = true token: true,
bot.transformers.desiredProperties.interaction.token = true message: true,
bot.transformers.desiredProperties.interaction.message = true // insert-next-line
// insert-next-line guildId: true,
bot.transformers.desiredProperties.interaction.guildId = true channelId: true,
bot.transformers.desiredProperties.interaction.channelId = true },
message: {
bot.transformers.desiredProperties.role.id = true id: true,
},
// insert-start
user: {
id: true,
},
role: {
id: true,
},
// insert-end
}
})
// REST OF YOUR CODE // REST OF YOUR CODE
``` ```
@@ -1464,25 +1464,37 @@ And now let's add the desired properties. In the `src/index.ts` we need just a f
```ts ```ts
// REST OF YOUR CODE // REST OF YOUR CODE
bot.transformers.desiredProperties.user.id = true export const bot = createBot({
token,
bot.transformers.desiredProperties.message.id = true desiredProperties: {
interaction: {
// insert-next-line id: true,
bot.transformers.desiredProperties.member.roles = true data: true,
type: true,
bot.transformers.desiredProperties.interaction.id = true user: true,
bot.transformers.desiredProperties.interaction.data = true token: true,
bot.transformers.desiredProperties.interaction.type = true // insert-next-line
bot.transformers.desiredProperties.interaction.user = true member: true,
bot.transformers.desiredProperties.interaction.token = true message: true,
// insert-next-line guildId: true,
bot.transformers.desiredProperties.interaction.member = true channelId: true,
bot.transformers.desiredProperties.interaction.message = true },
bot.transformers.desiredProperties.interaction.guildId = true message: {
bot.transformers.desiredProperties.interaction.channelId = true id: true,
},
bot.transformers.desiredProperties.role.id = true user: {
id: true,
},
role: {
id: true,
},
// insert-start
member: {
roles: true,
}
// insert-end
}
})
// REST OF YOUR CODE // REST OF YOUR CODE
``` ```
+17 -18
View File
@@ -34,7 +34,7 @@ const bot = createBot({
intents: Intents.Guilds | Intents.GuildMessages, // Or other intents that you might needs. intents: Intents.Guilds | Intents.GuildMessages, // Or other intents that you might needs.
events: { events: {
ready: data => { ready: data => {
console.log(`The shard ${data.shardId} is ready!`) bot.logger.info(`The shard ${data.shardId} is ready!`)
}, },
}, },
}) })
@@ -88,34 +88,33 @@ Discordeno's methods always perform one action only. A method will never call mu
## Understanding Desired Properties in Discordeno ## Understanding Desired Properties in Discordeno
:::tip
For more details checkout [the desired properties docs](./desired-properties.md)
:::
If we ran the code above (for example, by putting the code inside the ready event), the bot will send a message in the channel you specified (as long as it has the permissions to do so) with the content "Hello world. This is test message from Discordeno.". However, if we log to the console the message object that Discordeno return, we won't see many, if any, values on it. This is also the case for other events such as `MessageCreate`. But why is that? Well, this is because of a Discordeno feature called `Desired properties`. If we ran the code above (for example, by putting the code inside the ready event), the bot will send a message in the channel you specified (as long as it has the permissions to do so) with the content "Hello world. This is test message from Discordeno.". However, if we log to the console the message object that Discordeno return, we won't see many, if any, values on it. This is also the case for other events such as `MessageCreate`. But why is that? Well, this is because of a Discordeno feature called `Desired properties`.
Desired properties is a feature that reduce the memory usage of your application by removing properties that you don't use. For example, you might not be interested in knowing the topic of a channel, but Discord will always return it, therefore consuming more memory. This is why Discordeno requires you to explicitly set the properties that you want to keep and use. Desired properties is a feature that reduce the memory usage of your application by removing properties that you don't use. For example, you might not be interested in knowing the topic of a channel, but Discord will always return it, therefore consuming more memory. This is why Discordeno requires you to explicitly set the properties that you want to keep and use.
You can set which property you want to keep in the `bot.transformers.desiredProperties` object. Discordeno will default everything to false and you can set the values you want to keep to true manually like this: The main way to configure desired properties is using the `desiredProperties` object in `createBot`:
```ts ```ts
bot.transformers.desiredProperties.message.id = true const bot = createBot({
bot.transformers.desiredProperties.message.content = true // ... your exiting code
bot.transformers.desiredProperties.message.channelId = true desiredProperties: {
message: {
id: true,
content: true,
channelId: true,
},
},
})
``` ```
With the above 3 lines of code, we will be able to get the message ID, the channel ID and the message content\* of a specific message. The same thing can be said for the return object of `sendMessage` method and the `messageCreate` event With the above, we will be able to get the message ID, the channel ID and the message content\* of messages, this means that if we now log the message object from before we will find these 3 values.
We can also set the properties we want to keep with `{ id: true, content: true, channelId: true }`, but that would require us to specify all others keys in the object, and doing that would get extremely annoying.
\*: As long as the required privileged intent is enabled. \*: As long as the required privileged intent is enabled.
:::danger[Changing the default for Desired Properties]
THIS IS NOT RECOMMENDED IF YOU PLAN TO SHIP YOUR BOT TO PRODUCTION.
While not recommended, you can add `defaultDesiredPropertiesValue: true` to the first parameter object of the `createBot` function. This will set every desired property to true by default (you can still disable some if you want to). The reason why this is not recommended and considered deprecated is because while Desired Properties DO slow you down during development (needing to make sure you aren't using something that you won't have at runtime), they have a significant performance impact on both CPU and memory usage.
:::
:::warning[Typescript and Desired Properties]
We are aware that TypeScript has no idea which properties will be missing. We are working on fixing this issue.
:::
## Additional information on Discordeno ## Additional information on Discordeno
Here are some nice to know things about Discordeno that you might be interested, though some may be for more advanced use-cases. Here are some nice to know things about Discordeno that you might be interested, though some may be for more advanced use-cases.