Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for user-installable apps #228

Merged
merged 9 commits into from
Nov 2, 2024
28 changes: 14 additions & 14 deletions examples/with-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@
"#rootJson/*": "./src/*.json"
},
"dependencies": {
"@sapphire/discord-utilities": "^3.2.2",
"@sapphire/discord.js-utilities": "7.1.6",
"@sapphire/fetch": "^3.0.2",
"@sapphire/framework": "^5.0.7",
"@sapphire/plugin-api": "^6.1.1",
"@sapphire/plugin-editable-commands": "^4.0.2",
"@sapphire/discord-utilities": "^3.4.2",
"@sapphire/discord.js-utilities": "7.3.1",
"@sapphire/fetch": "^3.0.4",
"@sapphire/framework": "^5.3.0",
"@sapphire/plugin-api": "^7.0.0",
"@sapphire/plugin-editable-commands": "^4.0.3",
"@sapphire/plugin-logger": "^4.0.2",
"@sapphire/plugin-subcommands": "^6.0.3",
"@sapphire/time-utilities": "^1.7.12",
"@sapphire/type": "^2.4.4",
"@sapphire/utilities": "^3.15.3",
"discord.js": "^14.14.1"
"@sapphire/plugin-subcommands": "^7.0.1",
"@sapphire/time-utilities": "^1.7.13",
"@sapphire/type": "^2.5.1",
"@sapphire/utilities": "^3.18.0",
"discord.js": "^14.16.3"
},
"devDependencies": {
"@sapphire/cli": "^1.9.3",
"@sapphire/prettier-config": "^2.0.0",
"nodemon": "^3.0.3",
"npm-run-all2": "^6.1.1",
"prettier": "^3.2.4"
"nodemon": "^3.1.7",
"npm-run-all2": "^7.0.1",
"prettier": "^3.3.3"
},
"scripts": {
"sapphire": "sapphire",
Expand Down
28 changes: 14 additions & 14 deletions examples/with-javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@
"license": "UNLICENSE",
"type": "commonjs",
"dependencies": {
"@sapphire/discord-utilities": "^3.2.2",
"@sapphire/discord.js-utilities": "7.1.6",
"@sapphire/fetch": "^3.0.2",
"@sapphire/framework": "^5.0.7",
"@sapphire/plugin-api": "^6.1.1",
"@sapphire/plugin-editable-commands": "^4.0.2",
"@sapphire/discord-utilities": "^3.4.2",
"@sapphire/discord.js-utilities": "7.3.1",
"@sapphire/fetch": "^3.0.4",
"@sapphire/framework": "^5.3.0",
"@sapphire/plugin-api": "^7.0.0",
"@sapphire/plugin-editable-commands": "^4.0.3",
"@sapphire/plugin-logger": "^4.0.2",
"@sapphire/plugin-subcommands": "^6.0.3",
"@sapphire/time-utilities": "^1.7.12",
"@sapphire/type": "^2.4.4",
"@sapphire/utilities": "^3.15.3",
"discord.js": "^14.14.1"
"@sapphire/plugin-subcommands": "^7.0.1",
"@sapphire/time-utilities": "^1.7.13",
"@sapphire/type": "^2.5.1",
"@sapphire/utilities": "^3.18.0",
"discord.js": "^14.16.3"
},
"devDependencies": {
"@sapphire/cli": "^1.9.3",
"@sapphire/prettier-config": "^2.0.0",
"nodemon": "^3.0.3",
"npm-run-all2": "^6.1.1",
"prettier": "^3.2.4"
"nodemon": "^3.1.7",
"npm-run-all2": "^7.0.1",
"prettier": "^3.3.3"
},
"scripts": {
"sapphire": "sapphire",
Expand Down
40 changes: 20 additions & 20 deletions examples/with-swc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@
"license": "UNLICENSE",
"type": "commonjs",
"dependencies": {
"@sapphire/decorators": "^6.0.4",
"@sapphire/discord-utilities": "^3.2.2",
"@sapphire/discord.js-utilities": "7.1.6",
"@sapphire/fetch": "^3.0.2",
"@sapphire/framework": "^5.0.7",
"@sapphire/plugin-api": "^6.1.1",
"@sapphire/plugin-editable-commands": "^4.0.2",
"@sapphire/decorators": "^6.1.1",
"@sapphire/discord-utilities": "^3.4.2",
"@sapphire/discord.js-utilities": "7.3.1",
"@sapphire/fetch": "^3.0.4",
"@sapphire/framework": "^5.3.0",
"@sapphire/plugin-api": "^7.0.0",
"@sapphire/plugin-editable-commands": "^4.0.3",
"@sapphire/plugin-logger": "^4.0.2",
"@sapphire/plugin-subcommands": "^6.0.3",
"@sapphire/time-utilities": "^1.7.12",
"@sapphire/type": "^2.4.4",
"@sapphire/utilities": "^3.15.3",
"@sapphire/plugin-subcommands": "^7.0.1",
"@sapphire/time-utilities": "^1.7.13",
"@sapphire/type": "^2.5.1",
"@sapphire/utilities": "^3.18.0",
"@skyra/env-utilities": "^1.3.0",
"discord.js": "^14.14.1"
"discord.js": "^14.16.3"
},
"devDependencies": {
"@sapphire/cli": "^1.9.3",
"@sapphire/prettier-config": "^2.0.0",
"@sapphire/ts-config": "^5.0.0",
"@swc/cli": "^0.3.3",
"@swc/core": "^1.3.106",
"@types/node": "^20.11.5",
"@types/ws": "^8.5.10",
"npm-run-all2": "^6.1.1",
"prettier": "^3.2.4",
"tsc-watch": "^6.0.4",
"@sapphire/ts-config": "^5.0.1",
"@swc/cli": "^0.3.14",
"@swc/core": "^1.7.42",
"@types/node": "^20.17.5",
"@types/ws": "^8.5.13",
"npm-run-all2": "^7.0.1",
"prettier": "^3.3.3",
"tsc-watch": "^6.2.0",
"typescript": "~5.4.5"
},
"scripts": {
Expand Down
23 changes: 19 additions & 4 deletions examples/with-swc/src/commands/General/ping.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,45 @@
import { ApplyOptions } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';
import { send } from '@sapphire/plugin-editable-commands';
import { ApplicationCommandType, type Message } from 'discord.js';
import { ApplicationCommandType, ApplicationIntegrationType, InteractionContextType, type Message } from 'discord.js';

@ApplyOptions<Command.Options>({
description: 'ping pong'
})
export class UserCommand extends Command {
// Register slash and context menu command
public override registerApplicationCommands(registry: Command.Registry) {
// Create shared integration types and contexts
// These allow the command to be used in guilds and DMs
const integrationTypes: ApplicationIntegrationType[] = [ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall];
const contexts: InteractionContextType[] = [
InteractionContextType.BotDM,
InteractionContextType.Guild,
InteractionContextType.PrivateChannel
];

// Register slash command
registry.registerChatInputCommand({
name: this.name,
description: this.description
description: this.description,
integrationTypes,
contexts
});

// Register context menu command available from any message
registry.registerContextMenuCommand({
name: this.name,
type: ApplicationCommandType.Message
type: ApplicationCommandType.Message,
integrationTypes,
contexts
});

// Register context menu command available from any user
registry.registerContextMenuCommand({
name: this.name,
type: ApplicationCommandType.User
type: ApplicationCommandType.User,
integrationTypes,
contexts
});
}

Expand Down
5 changes: 4 additions & 1 deletion examples/with-swc/src/listeners/mentionPrefixOnly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { Listener } from '@sapphire/framework';
import type { Message } from 'discord.js';

export class UserEvent extends Listener<typeof Events.MentionPrefixOnly> {
public override async run(message: Message) {
public override run(message: Message) {
// Do nothing if we cannot send messages in the channel (eg. group DMs)
if (!message.channel.isSendable()) return;

const prefix = this.container.client.options.defaultPrefix;
return message.channel.send(prefix ? `My prefix in this guild is: \`${prefix}\`` : 'Cannot find any Prefix for Message Commands.');
}
Expand Down
36 changes: 18 additions & 18 deletions examples/with-tsup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@
"license": "UNLICENSE",
"type": "commonjs",
"dependencies": {
"@sapphire/decorators": "^6.0.4",
"@sapphire/discord-utilities": "^3.2.2",
"@sapphire/discord.js-utilities": "7.1.6",
"@sapphire/fetch": "^3.0.2",
"@sapphire/framework": "^5.0.7",
"@sapphire/plugin-api": "^6.1.1",
"@sapphire/plugin-editable-commands": "^4.0.2",
"@sapphire/decorators": "^6.1.1",
"@sapphire/discord-utilities": "^3.4.2",
"@sapphire/discord.js-utilities": "7.3.1",
"@sapphire/fetch": "^3.0.4",
"@sapphire/framework": "^5.3.0",
"@sapphire/plugin-api": "^7.0.0",
"@sapphire/plugin-editable-commands": "^4.0.3",
"@sapphire/plugin-logger": "^4.0.2",
"@sapphire/plugin-subcommands": "^6.0.3",
"@sapphire/time-utilities": "^1.7.12",
"@sapphire/type": "^2.4.4",
"@sapphire/utilities": "^3.15.3",
"@sapphire/plugin-subcommands": "^7.0.1",
"@sapphire/time-utilities": "^1.7.13",
"@sapphire/type": "^2.5.1",
"@sapphire/utilities": "^3.18.0",
"@skyra/env-utilities": "^1.3.0",
"discord.js": "^14.14.1"
"discord.js": "^14.16.3"
},
"devDependencies": {
"@sapphire/cli": "^1.9.3",
"@sapphire/prettier-config": "^2.0.0",
"@sapphire/ts-config": "^5.0.0",
"@types/node": "^20.11.5",
"@types/ws": "^8.5.10",
"npm-run-all2": "^6.1.1",
"prettier": "^3.2.4",
"tsup": "^8.0.1",
"@sapphire/ts-config": "^5.0.1",
"@types/node": "^20.17.5",
"@types/ws": "^8.5.13",
"npm-run-all2": "^7.0.1",
"prettier": "^3.3.3",
"tsup": "^8.3.5",
"typescript": "~5.4.5"
},
"scripts": {
Expand Down
23 changes: 19 additions & 4 deletions examples/with-tsup/src/commands/General/ping.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,45 @@
import { ApplyOptions } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';
import { send } from '@sapphire/plugin-editable-commands';
import { ApplicationCommandType, type Message } from 'discord.js';
import { ApplicationCommandType, ApplicationIntegrationType, InteractionContextType, type Message } from 'discord.js';

@ApplyOptions<Command.Options>({
description: 'ping pong'
})
export class UserCommand extends Command {
// Register slash and context menu command
public override registerApplicationCommands(registry: Command.Registry) {
// Create shared integration types and contexts
// These allow the command to be used in guilds and DMs
const integrationTypes: ApplicationIntegrationType[] = [ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall];
const contexts: InteractionContextType[] = [
InteractionContextType.BotDM,
InteractionContextType.Guild,
InteractionContextType.PrivateChannel
];

// Register slash command
registry.registerChatInputCommand({
name: this.name,
description: this.description
description: this.description,
integrationTypes,
contexts
});

// Register context menu command available from any message
registry.registerContextMenuCommand({
name: this.name,
type: ApplicationCommandType.Message
type: ApplicationCommandType.Message,
integrationTypes,
contexts
});

// Register context menu command available from any user
registry.registerContextMenuCommand({
name: this.name,
type: ApplicationCommandType.User
type: ApplicationCommandType.User,
integrationTypes,
contexts
});
}

Expand Down
5 changes: 4 additions & 1 deletion examples/with-tsup/src/listeners/mentionPrefixOnly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { Listener } from '@sapphire/framework';
import type { Message } from 'discord.js';

export class UserEvent extends Listener<typeof Events.MentionPrefixOnly> {
public override async run(message: Message) {
public override run(message: Message) {
// Do nothing if we cannot send messages in the channel (eg. group DMs)
if (!message.channel.isSendable()) return;

const prefix = this.container.client.options.defaultPrefix;
return message.channel.send(prefix ? `My prefix in this guild is: \`${prefix}\`` : 'Cannot find any Prefix for Message Commands.');
}
Expand Down
36 changes: 18 additions & 18 deletions examples/with-typescript-complete/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@
"license": "UNLICENSE",
"type": "commonjs",
"dependencies": {
"@sapphire/decorators": "^6.0.4",
"@sapphire/discord-utilities": "^3.2.2",
"@sapphire/discord.js-utilities": "7.1.6",
"@sapphire/fetch": "^3.0.2",
"@sapphire/framework": "^5.0.7",
"@sapphire/plugin-api": "^6.1.1",
"@sapphire/plugin-editable-commands": "^4.0.2",
"@sapphire/decorators": "^6.1.1",
"@sapphire/discord-utilities": "^3.4.2",
"@sapphire/discord.js-utilities": "7.3.1",
"@sapphire/fetch": "^3.0.4",
"@sapphire/framework": "^5.3.0",
"@sapphire/plugin-api": "^7.0.0",
"@sapphire/plugin-editable-commands": "^4.0.3",
"@sapphire/plugin-logger": "^4.0.2",
"@sapphire/plugin-subcommands": "^6.0.3",
"@sapphire/time-utilities": "^1.7.12",
"@sapphire/type": "^2.4.4",
"@sapphire/utilities": "^3.15.3",
"@sapphire/plugin-subcommands": "^7.0.1",
"@sapphire/time-utilities": "^1.7.13",
"@sapphire/type": "^2.5.1",
"@sapphire/utilities": "^3.18.0",
"@skyra/env-utilities": "^1.3.0",
"colorette": "^2.0.20",
"discord.js": "^14.14.1"
"discord.js": "^14.16.3"
},
"devDependencies": {
"@sapphire/cli": "^1.9.3",
"@sapphire/prettier-config": "^2.0.0",
"@sapphire/ts-config": "^5.0.0",
"@types/node": "^20.11.5",
"@types/ws": "^8.5.10",
"npm-run-all2": "^6.1.1",
"prettier": "^3.2.4",
"tsc-watch": "^6.0.4",
"@sapphire/ts-config": "^5.0.1",
"@types/node": "^20.17.5",
"@types/ws": "^8.5.13",
"npm-run-all2": "^7.0.1",
"prettier": "^3.3.3",
"tsc-watch": "^6.2.0",
"typescript": "~5.4.5"
},
"scripts": {
Expand Down
Loading