McDefault - Hello y'all Im trying to follow the c...

Hello y'all> Im trying to follow the create basic slash cmd guide, but the example code is giving an error on isMessageInstance(msg) Type not assignable https://www.sapphirejs.dev/docs/Guide/getting-started/creating-a-basic-app-command
import { isMessageInstance } from '@sapphire/discord.js-utilities';
import { ChatInputCommand, Command } from "@sapphire/framework";

export class PingCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) {
super(context, { ...options });
}
public override registerApplicationCommands(registry: ChatInputCommand.Registry) {
registry.registerChatInputCommand((builder) =>
builder.setName('ping').setDescription('Ping bot to see if it is alive')
);
}
public async chatInputRun(interaction: Command.ChatInputInteraction) {
const msg = await interaction.reply({ content: `Ping?`, ephemeral: false, fetchReply: true });
if (isMessageInstance(msg)) {
const diff = msg.createdTimestamp - interaction.createdTimestamp;
const ping = Math.round(this.container.client.ws.ping);
return interaction.editReply(`Pong 🏓! (Round trip took: ${diff}ms. Heartbeat: ${ping}ms.)`);
}
return interaction.editReply('Failed to retrieve ping :(');
}
}
import { isMessageInstance } from '@sapphire/discord.js-utilities';
import { ChatInputCommand, Command } from "@sapphire/framework";

export class PingCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) {
super(context, { ...options });
}
public override registerApplicationCommands(registry: ChatInputCommand.Registry) {
registry.registerChatInputCommand((builder) =>
builder.setName('ping').setDescription('Ping bot to see if it is alive')
);
}
public async chatInputRun(interaction: Command.ChatInputInteraction) {
const msg = await interaction.reply({ content: `Ping?`, ephemeral: false, fetchReply: true });
if (isMessageInstance(msg)) {
const diff = msg.createdTimestamp - interaction.createdTimestamp;
const ping = Math.round(this.container.client.ws.ping);
return interaction.editReply(`Pong 🏓! (Round trip took: ${diff}ms. Heartbeat: ${ping}ms.)`);
}
return interaction.editReply('Failed to retrieve ping :(');
}
}
Sapphire Framework
Creating a basic slash command | Sapphire
This section covers the absolute minimum for setting up a slash command. We have an entire "Application Commands"
M
McDefault530d ago
Error when loading 'E:\Users\Max\Documents\simple-typescript-starter\src\commands\ping.ts': src/commands/ping.ts:15:27 - error TS2345: Argument of type 'APIMessage | Message<boolean>' is not assignable to parameter of type 'Messa
ge<boolean> | APIMessage'.
Type 'APIMessage' is not assignable to type 'Message<boolean> | APIMessage'.
Type 'import("E:/Users/Max/Documents/simple-typescript-starter/node_modules/discord.js/node_modules/discord-api-types/payloads/v9/channel").APIMessage' is not assignable to type 'import("E:/Users/Max/Documents/simple-typescri
pt-starter/node_modules/discord-api-types/payloads/v9/channel").APIMessage'.
The types of 'author.flags' are incompatible between these types.
Type 'import("E:/Users/Max/Documents/simple-typescript-starter/node_modules/discord.js/node_modules/discord-api-types/payloads/v9/user").UserFlags | undefined' is not assignable to type 'import("E:/Users/Max/Documents/sim
ple-typescript-starter/node_modules/discord-api-types/payloads/v9/user").UserFlags | undefined'.
Type 'import("E:/Users/Max/Documents/simple-typescript-starter/node_modules/discord.js/node_modules/discord-api-types/payloads/v9/user").UserFlags' is not assignable to type 'UserFlags'.

15 if (isMessageInstance(msg)) {
Error when loading 'E:\Users\Max\Documents\simple-typescript-starter\src\commands\ping.ts': src/commands/ping.ts:15:27 - error TS2345: Argument of type 'APIMessage | Message<boolean>' is not assignable to parameter of type 'Messa
ge<boolean> | APIMessage'.
Type 'APIMessage' is not assignable to type 'Message<boolean> | APIMessage'.
Type 'import("E:/Users/Max/Documents/simple-typescript-starter/node_modules/discord.js/node_modules/discord-api-types/payloads/v9/channel").APIMessage' is not assignable to type 'import("E:/Users/Max/Documents/simple-typescri
pt-starter/node_modules/discord-api-types/payloads/v9/channel").APIMessage'.
The types of 'author.flags' are incompatible between these types.
Type 'import("E:/Users/Max/Documents/simple-typescript-starter/node_modules/discord.js/node_modules/discord-api-types/payloads/v9/user").UserFlags | undefined' is not assignable to type 'import("E:/Users/Max/Documents/sim
ple-typescript-starter/node_modules/discord-api-types/payloads/v9/user").UserFlags | undefined'.
Type 'import("E:/Users/Max/Documents/simple-typescript-starter/node_modules/discord.js/node_modules/discord-api-types/payloads/v9/user").UserFlags' is not assignable to type 'UserFlags'.

15 if (isMessageInstance(msg)) {
{
"name": "typescript-starter",
"version": "1.0.0",
"description": "A basic typescript app starter for newbies in 2022.",
"main": "src/index.js",
"scripts": {
"build": "rimraf ./build && tsc",
"start:dev": "nodemon",
"start": "npm run build && node build/index.js",
"lint": "eslint . --ext .ts",
"prettier-format": "run-script-os",
"prettier-format:win32": "prettier --config .prettierrc \"./src/**/*.ts\" --write",
"prettier-format:darwin:linux": "prettier --config .prettierrc 'src/**/*.ts' --write",
"prettier-format:default": "prettier --config .prettierrc 'src/**/*.ts' --write",
"prettier-watch": "run-script-os",
"prettier-watch:win32": "onchange \"src/**/*.ts\" -- prettier --write {{changed}}",
"prettier-watch:darwin:linux": "onchange 'src/**/*.ts' -- prettier --write {{changed}}",
"prettier-watch:default": "onchange 'src/**/*.ts' -- prettier --write {{changed}}",
"test": "jest",
"test:dev": "jest --watchAll"
},
"husky": {
"hooks": {
"pre-commit": "npm run test && npm run prettier-format && npm run lint"
}
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@types/jest": "^28.1.6",
"@types/node": "^18.6.1",
"@typescript-eslint/eslint-plugin": "^5.31.0",
"@typescript-eslint/parser": "^5.31.0",
"eslint": "^8.20.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jest": "^26.6.0",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.1",
"jest": "^28.1.3",
"nodemon": "^2.0.19",
"onchange": "^7.1.0",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"run-script-os": "^1.1.6",
"ts-jest": "^28.0.7",
"ts-node": "^10.9.1",
"typescript": "^4.7.4"
},
"dependencies": {
"@sapphire/framework": "^3.1.3",
"discord.js": "^13.9.0"
}
}
{
"name": "typescript-starter",
"version": "1.0.0",
"description": "A basic typescript app starter for newbies in 2022.",
"main": "src/index.js",
"scripts": {
"build": "rimraf ./build && tsc",
"start:dev": "nodemon",
"start": "npm run build && node build/index.js",
"lint": "eslint . --ext .ts",
"prettier-format": "run-script-os",
"prettier-format:win32": "prettier --config .prettierrc \"./src/**/*.ts\" --write",
"prettier-format:darwin:linux": "prettier --config .prettierrc 'src/**/*.ts' --write",
"prettier-format:default": "prettier --config .prettierrc 'src/**/*.ts' --write",
"prettier-watch": "run-script-os",
"prettier-watch:win32": "onchange \"src/**/*.ts\" -- prettier --write {{changed}}",
"prettier-watch:darwin:linux": "onchange 'src/**/*.ts' -- prettier --write {{changed}}",
"prettier-watch:default": "onchange 'src/**/*.ts' -- prettier --write {{changed}}",
"test": "jest",
"test:dev": "jest --watchAll"
},
"husky": {
"hooks": {
"pre-commit": "npm run test && npm run prettier-format && npm run lint"
}
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@types/jest": "^28.1.6",
"@types/node": "^18.6.1",
"@typescript-eslint/eslint-plugin": "^5.31.0",
"@typescript-eslint/parser": "^5.31.0",
"eslint": "^8.20.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jest": "^26.6.0",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.1",
"jest": "^28.1.3",
"nodemon": "^2.0.19",
"onchange": "^7.1.0",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"run-script-os": "^1.1.6",
"ts-jest": "^28.0.7",
"ts-node": "^10.9.1",
"typescript": "^4.7.4"
},
"dependencies": {
"@sapphire/framework": "^3.1.3",
"discord.js": "^13.9.0"
}
}
F
Favna530d ago
deduplicate your dependencies. You have conflicting versions of discord-api-types also good lord man clean up those scripts. all that prettier-format:win32 is completely unnecessary prettier \"./src/**/*.ts\" --write works on all platforms and automatically loads .prettierrc
M
McDefault530d ago
Thank you for your reply. What duplicates are you referring to exactly? I'm not sure which one your mean
"@types/jest": "^28.1.6",
"@types/node": "^18.6.1",
"@types/jest": "^28.1.6",
"@types/node": "^18.6.1",
"ts-jest": "^28.0.7",
"ts-node": "^10.9.1",
"ts-jest": "^28.0.7",
"ts-node": "^10.9.1",
these?
F
Favna530d ago
those arent the same so no
F
Favna530d ago
im referring to running https://docs.npmjs.com/cli/v9/commands/npm-dedupe?v=true or the yarn equivalent
npm-dedupe | npm Docs
Reduce duplication in the package tree
M
McDefault530d ago
Right. Thank you for the suggestion. I have run it now and still seem to have issues
F
Favna530d ago
uh update your deps most of them are outdated sapphire is on 3.1.4, djs is 13.12.0, etc. npx npm-upgrade when using npm pretty sure djs 13.9 just has a different discord-api-types transient dep than sapphire 3.1.3 does
M
McDefault530d ago
yeah was about to ask that thx not v14 right
F
Favna530d ago
no 13.12.0 I guess npm-upgrade might not list that... common npm L compared to yarn mmLol
M
McDefault530d ago
ill just do it myself lol apart from that npx npm-upgrade is pretty handy
F
Favna530d ago
just use https://marketplace.visualstudio.com/items?itemName=pflannery.vscode-versionlens otherwise, it offers a similar but offers different options for semver scoping
Version Lens - Visual Studio Marketplace
Extension for Visual Studio Code - Shows the latest version for each package using code lens
F
Favna530d ago
(gif in the readme)
M
McDefault530d ago
Im on webstorm
F
Favna530d ago
oh webstorm has it integrated lol
M
McDefault530d ago
still same error lol
{
"name": "typescript-starter",
"version": "1.0.0",
"description": "A basic typescript app starter for newbies in 2022.",
"main": "src/index.js",
"scripts": {
"build": "rimraf ./build && tsc",
"start:dev": "nodemon",
"start": "npm run build && node build/index.js",
"lint": "eslint . --ext .ts",
"prettier-format": "run-script-os",
"prettier-format:win32": "prettier --config .prettierrc \"./src/**/*.ts\" --write",
"prettier-format:darwin:linux": "prettier --config .prettierrc 'src/**/*.ts' --write",
"prettier-format:default": "prettier --config .prettierrc 'src/**/*.ts' --write",
"prettier-watch": "run-script-os",
"prettier-watch:win32": "onchange \"src/**/*.ts\" -- prettier --write {{changed}}",
"prettier-watch:darwin:linux": "onchange 'src/**/*.ts' -- prettier --write {{changed}}",
"prettier-watch:default": "onchange 'src/**/*.ts' -- prettier --write {{changed}}",
"test": "jest",
"test:dev": "jest --watchAll"
},
"husky": {
"hooks": {
"pre-commit": "npm run test && npm run prettier-format && npm run lint"
}
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@types/jest": "^29.2.3",
"@types/node": "^18.11.9",
"@typescript-eslint/eslint-plugin": "^5.44.0",
"@typescript-eslint/parser": "^5.44.0",
"eslint": "^8.28.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jest": "^27.1.5",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.2",
"jest": "^29.3.1",
"nodemon": "^2.0.20",
"onchange": "^7.1.0",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"run-script-os": "^1.1.6",
"ts-jest": "^29.0.3",
"ts-node": "^10.9.1",
"typescript": "^4.9.3"
},
"dependencies": {
"@sapphire/framework": "^3.1.4",
"discord.js": "^13.12.0"
}
}
{
"name": "typescript-starter",
"version": "1.0.0",
"description": "A basic typescript app starter for newbies in 2022.",
"main": "src/index.js",
"scripts": {
"build": "rimraf ./build && tsc",
"start:dev": "nodemon",
"start": "npm run build && node build/index.js",
"lint": "eslint . --ext .ts",
"prettier-format": "run-script-os",
"prettier-format:win32": "prettier --config .prettierrc \"./src/**/*.ts\" --write",
"prettier-format:darwin:linux": "prettier --config .prettierrc 'src/**/*.ts' --write",
"prettier-format:default": "prettier --config .prettierrc 'src/**/*.ts' --write",
"prettier-watch": "run-script-os",
"prettier-watch:win32": "onchange \"src/**/*.ts\" -- prettier --write {{changed}}",
"prettier-watch:darwin:linux": "onchange 'src/**/*.ts' -- prettier --write {{changed}}",
"prettier-watch:default": "onchange 'src/**/*.ts' -- prettier --write {{changed}}",
"test": "jest",
"test:dev": "jest --watchAll"
},
"husky": {
"hooks": {
"pre-commit": "npm run test && npm run prettier-format && npm run lint"
}
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@types/jest": "^29.2.3",
"@types/node": "^18.11.9",
"@typescript-eslint/eslint-plugin": "^5.44.0",
"@typescript-eslint/parser": "^5.44.0",
"eslint": "^8.28.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jest": "^27.1.5",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.2",
"jest": "^29.3.1",
"nodemon": "^2.0.20",
"onchange": "^7.1.0",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"run-script-os": "^1.1.6",
"ts-jest": "^29.0.3",
"ts-node": "^10.9.1",
"typescript": "^4.9.3"
},
"dependencies": {
"@sapphire/framework": "^3.1.4",
"discord.js": "^13.12.0"
}
}
F
Favna530d ago
idk man. dump code on gh or something,.
M
McDefault530d ago
Ehh ima ditch this framework 🚀 Ill check back in few months to see if it will improve ty for the help anyways
F
Favna530d ago
this issue is not even related to the framework but sure bye i guess
S
Sawako530d ago
._.
V
vladdy530d ago
I hate to say it but this isn't an issue in the framework... Without a reproduction sample we cannot help. When in doubt, if you have clashing versions, nuke package-lock and node_modules and reinstall deps
M
McDefault530d ago
I doubt thats the case, I did all the updates and dedupe If you want, you can toss a package.json to me Docs should def. be updated for new people not known to the fw
F
Favna530d ago
we have a guide, we have a cli to generate a production ready example bot, we have many examples, we have many other bots using the fw. What more do you want. Did you even read the guide for starters.
M
McDefault530d ago
that sounds promising using CLI helped thanks for the tip awesome docker implementation too, kudos
Want results from more Discord servers?
Add your server
More Posts
chmod - does sapphire support djs 14?does sapphire support djs 14?RuiNtD - How to ensure removed application command...How to ensure removed commands are unregistered?WhacK - I upgraded my existing sapphire bot to typ...I upgraded my existing sapphire bot to typescript and altered some things. My commands are not beingArarou - Is this smth fixable? It's never done thi...Is this smth fixable? It's never done this before and I don't know whats causing it.Fractune - Hello, I'd like to know why my `if` jum...Hello, I'd like to know why my `if` jumps straight to `else` while `!isNaN(parseInt(tags.slice(-1)[0Abdo Hosnie - it doesn't play anything (it doesn't play anything : (DelxHQ - Is there anyway I can defer all of my com...Is there anyway I can defer all of my commands?ShirayukiHaruka - **[Sapphire Logging]**Hello! I'...**[Sapphire Logging]** Hello! I've been using Sapphire for a while now, and wondering if there is a Ben855 - I can't seem to get slash subcommands wor...I can't seem to get slash subcommands working. I'm able to register them just fine but my chatInputRStealth - Any idea what's going on here?Any idea what's going on here?RVX - new to coding here. (very new) how do i un...new to coding here. (very new) how do i unregister a command? looks like registering a command an! 𝑱𝒂𝒎𝒆𝒔__ - Hello, I need help with my backup cod...Hello, I need help with my backup code. The rooms are created correctly but the categories are creatBigBrainAFK - So how does one interact with Forum ...So how does one interact with Forum channels in sapphireSlinky - Hello, I just started using the framework...Hello, I just started using the framework yesterday and currently having a issue trying to reset theHyperfire - How would i ago about adding custom fi...How would i ago about adding custom fields to commands? Like for example aliasespochiko - Hello! does anyone kno whow to fix this ...Hello! does anyone kno whow to fix this problem? ive been trying to figure out why for the past 30 mNitsua - Editing a previously ran slash command re...Editing a previously ran slash command results in an error. ``` Encountered error on chat input comwilluhmjs - ```jsValidationError s.string Exp...```js ValidationError > s.string Expected a string primitive Received: | undefined at Stsam - ```srcconfig.ts737 - error TS2345 Argum...``` src/config.ts:7:37 - error TS2345: Argument of type 'string' is not assignable to parameter of tRhys - ^Sort of related to above, does inheritance...^Sort of related to above, does inheritance work with commands? I've got a few commands for openin