Skip to content

Commit

Permalink
feat(qbox): deprecated command
Browse files Browse the repository at this point in the history
Co-authored-by: David Malchin <[email protected]>
  • Loading branch information
SSnowly and D4isDAVID authored Oct 17, 2024
1 parent 66e7dce commit 84043c6
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 0 deletions.
99 changes: 99 additions & 0 deletions src/components/qbox/commands/deprecated.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import {
APIInteractionResponseCallbackData,
ApplicationCommandOptionType,
ApplicationCommandType,
} from '@discordjs/core';
import {
bold,
hideLinkEmbed,
hyperlink,
inlineCode,
userMention,
} from '@discordjs/formatters';
import {
fivemDocsUrl,
fivemNativesUrl,
githubUrl,
oxUrl,
} from '../constants.js';
import { ChatInputCommand } from '/components/types.js';
import { mapChatInputOptionValues } from '/utils/interactions.js';

const deprecated: Record<string, string | [string, string]> = {
connectqueue: ["Use qbx_core's built-in queue.", 'unused'],
interact_sound: [
`Use FiveM ${hyperlink('native audio', hideLinkEmbed(`${fivemNativesUrl}/?_0x7FF4944CC209192D`))} functionality.`,
'unused',
],
PolyZone: `Use ${hyperlink(inlineCode('lib.zones'), hideLinkEmbed(`${oxUrl}/ox_lib/Modules/Zones/Shared`))}.`,
['qbx-anticheat']: 'None. Anticheat resources are not recommended.',
qbx_apartments: `Use ${hyperlink('qbx_properties', hideLinkEmbed(`${githubUrl}/qbx_properties`))}.`,
qbx_commandbinding: `Use FiveM's native ${hyperlink(inlineCode('bind'), hideLinkEmbed(`${fivemDocsUrl}/client-manual/console-commands/#bind-mapper-input-command`))} command.`,
qbx_crypto: 'None.',
qbx_fitbit: 'None.',
['qbx-hotdogjob']: 'None.',
qbx_houses: `Use ${hyperlink('qbx_properties', hideLinkEmbed(`${githubUrl}/qbx_properties`))}.`,
qbx_interior: 'None. Housing resources provide their own interior system.',
qbx_loading: `Use ${hyperlink('D4isDAVID/loadscreen', hideLinkEmbed('https://github.com/D4isDAVID/loadscreen'))}.`,
qbx_lockpick: `Use ${hyperlink(inlineCode('lib.skillCheck'), hideLinkEmbed(`${oxUrl}/ox_lib/Modules/Interface/Client/skillcheck`))} or a custom solution.`,
['qbx-multicharacter']: "Use qbx_core's built-in character selection.",
qbx_phone: `Use ${hyperlink('project-error/npwd', hideLinkEmbed('https://github.com/project-error/npwd'))}.`,
['qbx-printer']: 'None.',
qbx_prison: `Use ${hyperlink('xT-Development/xt-prison', hideLinkEmbed('https://github.com/xT-Development/xt-prison'))}.`,
qbx_skillbar: `Use ${hyperlink(inlineCode('lib.skillCheck'), hideLinkEmbed(`${oxUrl}/ox_lib/Modules/Interface/Client/skillcheck`))}.`,
qbx_traphouse: 'None.',
qbx_tunerchip: 'None.',
qbx_vehiclefailure: `Use ${hyperlink('QuantumMalice/vehiclehandler', hideLinkEmbed('https://github.com/QuantumMalice/vehiclehandler'))}.`,
qbx_weathersync: `Use ${hyperlink('Renewed-Scripts/Renewed-Weathersync', hideLinkEmbed('https://github.com/Renewed-Scripts/Renewed-Weathersync'))}.`,
};
const choices = Object.keys(deprecated).map((k) => ({ name: k, value: k }));

export const deprecatedCommand = {
data: {
type: ApplicationCommandType.ChatInput,
name: 'deprecated',
description: 'Send information about an archived or unused resource',
options: [
{
type: ApplicationCommandOptionType.String,
name: 'resource',
description: 'An optional exact resource to talk about',
choices,
},
{
type: ApplicationCommandOptionType.User,
name: 'mention',
description: 'An optional user to mention',
},
],
},
async execute({ api, data: interaction }) {
const { resource, mention } = mapChatInputOptionValues(
interaction.data,
) as { resource: string | undefined; mention: string | undefined };

const response: APIInteractionResponseCallbackData = {
content: mention ? `${userMention(mention)} ` : '',
};

if (resource && resource in deprecated) {
const obj = deprecated[resource];
const alternative = typeof obj === 'string' ? obj : obj![0];
const keyword = typeof obj === 'string' ? 'archived' : obj![1];

response.content! += `${bold(`${resource} is ${keyword}.`)}
Recommended alternative: ${alternative}`;
} else {
response.content! += `${bold("The resource you've mentioned is archived or unused.")}
Sometimes we deem a resource (sometimes one of our own) to be unnecessary or not up to par, whether because we found an alternative solution or just because it isn't needed anymore.
In such cases, the GitHub repository for such resource will be archived—not accepting any more changes.
You should use a recommended alternative instead.`;
}

await api.interactions.reply(
interaction.id,
interaction.token,
response,
);
},
} satisfies ChatInputCommand;
2 changes: 2 additions & 0 deletions src/components/qbox/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export const siteUrl = 'https://qbox.re';
export const docsUrl = 'https://docs.qbox.re';
export const oxUrl = 'https://overextended.dev';
export const fivemDocsUrl = 'https://docs.fivem.net/docs';
export const fivemNativesUrl = 'https://docs.fivem.net/natives';
export const githubUrl = `https://github.com/Qbox-project`;
export const githubReposApi = 'https://api.github.com/repos/Qbox-project';
export const metricsResourceApi = 'https://api.5metrics.dev/getResource';
Expand Down
2 changes: 2 additions & 0 deletions src/components/qbox/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component } from '../types.js';
import { aboutCommand } from './commands/about.js';
import { builtinCommand } from './commands/builtin.js';
import { compatCommand } from './commands/compat.js';
import { deprecatedCommand } from './commands/deprecated.js';
import { docsCommand } from './commands/docs.js';
import { onesyncCommand } from './commands/onesync.js';
import { recipesCommand } from './commands/recipes.js';
Expand All @@ -14,6 +15,7 @@ export default {
aboutCommand,
builtinCommand,
compatCommand,
deprecatedCommand,
docsCommand,
onesyncCommand,
recipesCommand,
Expand Down

0 comments on commit 84043c6

Please sign in to comment.