Skip to content

Commit

Permalink
Add support for user-installable apps
Browse files Browse the repository at this point in the history
  • Loading branch information
coopw1 committed Sep 9, 2024
1 parent fc9c14f commit 5480a6a
Show file tree
Hide file tree
Showing 20 changed files with 553 additions and 237 deletions.
730 changes: 497 additions & 233 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/commands/general/big.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ module.exports = {
],
},
],
contexts: [0, 1, 2],
integrationTypes: [0, 1],

callback: async (client, interaction) => {
const { brainzUsername, listenBrainzToken } = await getAuth(interaction);
Expand Down
2 changes: 2 additions & 0 deletions src/commands/general/brainz.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ module.exports = {
required: false,
},
],
contexts: [0, 1, 2],
integrationTypes: [0, 1],

callback: async (client, interaction) => {
let buttonRow1;
Expand Down
2 changes: 2 additions & 0 deletions src/commands/general/compare.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ module.exports = {
required: false,
},
],
contexts: [0, 1, 2],
integrationTypes: [0, 1],

callback: async (client, interaction) => {
const { brainzUsername, listenBrainzToken } = await getAuth(interaction);
Expand Down
2 changes: 2 additions & 0 deletions src/commands/general/recent.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ module.exports = {
required: false,
},
],
contexts: [0, 1, 2],
integrationTypes: [0, 1],

callback: async (client, interaction) => {
const { brainzUsername, listenBrainzToken } = await getAuth(interaction);
Expand Down
2 changes: 2 additions & 0 deletions src/commands/general/top.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ module.exports = {
],
},
],
contexts: [0, 1, 2],
integrationTypes: [0, 1],

callback: async (client, interaction) => {
const noAuthNeeded =
Expand Down
2 changes: 2 additions & 0 deletions src/commands/images/YIM.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ module.exports = {
],
},
],
contexts: [0, 1, 2],
integrationTypes: [0, 1],

callback: async (client, interaction) => {
const { brainzUsername } = await getAuth(interaction);
Expand Down
2 changes: 2 additions & 0 deletions src/commands/images/art.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ module.exports = {
],
},
],
contexts: [0, 1, 2],
integrationTypes: [0, 1],

callback: async (client, interaction) => {
const { brainzUsername } = await getAuth(interaction);
Expand Down
4 changes: 3 additions & 1 deletion src/commands/images/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ module.exports = {
],
},
],
// deleted: Boolean,
contexts: [0, 1, 2],
integrationTypes: [0, 1],

callback: async (client, interaction) => {
const { brainzUsername } = await getAuth(interaction);
if (interaction.replied) {
Expand Down
2 changes: 2 additions & 0 deletions src/commands/images/cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ module.exports = {
],
},
],
contexts: [0, 1, 2],
integrationTypes: [0, 1],

callback: async (client, interaction) => {
const { brainzUsername, listenBrainzToken } = await getAuth(interaction);
Expand Down
2 changes: 2 additions & 0 deletions src/commands/misc/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ module.exports = {
// required: false,
// },
// ],
contexts: [0, 1, 2],
integrationTypes: [0, 1],

callback: async (client, interaction) => {
const embed = new EmbedBuilder({
Expand Down
2 changes: 2 additions & 0 deletions src/commands/misc/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ module.exports = {
name: "info",
description: "Info",
category: "Misc",
contexts: [0, 1, 2],
integrationTypes: [0, 1],

callback: async (client, interaction) => {
const allUserData = await userData.find();
Expand Down
2 changes: 2 additions & 0 deletions src/commands/misc/ping.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module.exports = {
name: "ping",
description: "pong!",
category: "Misc",
contexts: [0, 1, 2],
integrationTypes: [0, 1],

callback: async (client, interaction) => {
await interaction.deferReply();
Expand Down
2 changes: 2 additions & 0 deletions src/commands/misc/sponsor.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module.exports = {
name: "sponsor",
description: "Display info about sponsoring the bot!",
category: "Misc",
contexts: [0, 1, 2],
integrationTypes: [0, 1],

callback: async (client, interaction) => {
const embed = new EmbedBuilder({
Expand Down
2 changes: 2 additions & 0 deletions src/commands/misc/vote.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ module.exports = {
name: "vote",
description: "Vote for the bot!!",
category: "Misc",
contexts: [0, 1, 2],
integrationTypes: [0, 1],

callback: async (client, interaction) => {
const votedStatus = getVoteStatus(interaction);
Expand Down
2 changes: 2 additions & 0 deletions src/commands/tools/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ module.exports = {
],
},
],
contexts: [0, 1, 2],
integrationTypes: [0, 1],

callback: async (client, interaction) => {
await interaction.deferReply();
Expand Down
2 changes: 2 additions & 0 deletions src/commands/userSettings/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ module.exports = {
},
],
category: "Settings",
contexts: [0, 1, 2],
integrationTypes: [0, 1],

callback: async (client, interaction) => {
// Check if user has provided a token
Expand Down
3 changes: 2 additions & 1 deletion src/commands/userSettings/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ module.exports = {
name: "user",
description: "Save your ListenBrainz username without needing a token!",
type: ApplicationCommandOptionType.Subcommand,
required: false,
options: [
{
name: "username",
Expand All @@ -25,6 +24,8 @@ module.exports = {
],
},
],
contexts: [0, 1, 2],
integrationTypes: [0, 1],

callback: async (client, interaction) => {
if (interaction.options.getSubcommand() === "user") {
Expand Down
7 changes: 6 additions & 1 deletion src/events/ready/01registerCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ module.exports = async (client) => {
const applicationCommands = await getApplicationCommands(client);

for (const localCommand of localCommands) {
const { name, description, options } = localCommand;
const { name, description, options, contexts, integrationTypes } =
localCommand;

const existingCommand = await applicationCommands.cache.find(
(cmd) => cmd.name === name
Expand All @@ -25,6 +26,8 @@ module.exports = async (client) => {
await applicationCommands.edit(existingCommand.id, {
description,
options,
contexts,
integrationTypes,
});

console.log(`Edited command: "${name}".`);
Expand All @@ -41,6 +44,8 @@ module.exports = async (client) => {
name,
description,
options,
contexts,
integrationTypes,
});
console.log(`Edited command: "${name}".`);
}
Expand Down
16 changes: 15 additions & 1 deletion src/utils/areCommandsDifferent.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = (existingCommand, localCommand) => {
if (
localOption.description !== existingOption.description ||
localOption.type !== existingOption.type ||
(localOption.required || false) !== existingOption.required ||
localOption.required !== existingOption.required ||
(localOption.choices?.length || 0) !==
(existingOption.choices?.length || 0) ||
areChoicesDifferent(
Expand All @@ -46,8 +46,22 @@ module.exports = (existingCommand, localCommand) => {
if (
existingCommand.description !== localCommand.description ||
existingCommand.options?.length !== (localCommand.options?.length || 0) ||
(localCommand.contexts !== undefined &&
JSON.stringify(existingCommand.contexts) !=
JSON.stringify(localCommand.contexts)) ||
(localCommand.integrationTypes !== undefined &&
JSON.stringify(existingCommand.integrationTypes) !==
JSON.stringify(localCommand.integrationTypes)) ||
areOptionsDifferent(existingCommand.options, localCommand.options || [])
) {
if (existingCommand.name === "big") {
console.log(existingCommand.options);
console.log(localCommand.options);
console.log(
JSON.stringify(existingCommand.options) !=
JSON.stringify(localCommand.options)
);
}
return true;
}

Expand Down

0 comments on commit 5480a6a

Please sign in to comment.