mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 10:03:31 +01:00
chore: move website and guide out of packages
This commit is contained in:
22
apps/website/src/util/constants.ts
Normal file
22
apps/website/src/util/constants.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
export const PACKAGES = ['builders', 'collection', 'proxy', 'rest', 'util', 'voice', 'ws'];
|
||||
|
||||
export const DESCRIPTION =
|
||||
"discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.";
|
||||
|
||||
export const CODE_EXAMPLE = `import { Client, GatewayIntentBits } from 'discord.js';
|
||||
|
||||
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
|
||||
|
||||
client.on('ready', () => {
|
||||
console.log(\`Logged in as \${client.user.tag}!\`);
|
||||
});
|
||||
|
||||
client.on('interactionCreate', async (interaction) => {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
if (interaction.commandName === 'ping') {
|
||||
await interaction.reply('Pong!');
|
||||
}
|
||||
});
|
||||
|
||||
await client.login(TOKEN);`;
|
||||
4
apps/website/src/util/fetcher.ts
Normal file
4
apps/website/src/util/fetcher.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export const fetcher = async (url: string) => {
|
||||
const res = await fetch(url);
|
||||
return res.json();
|
||||
};
|
||||
33
apps/website/src/util/model.server.ts
Normal file
33
apps/website/src/util/model.server.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { findPackage, ApiNodeJSONEncoder } from '@discordjs/api-extractor-utils';
|
||||
import type { ApiEntryPoint, ApiModel } from '@microsoft/api-extractor-model';
|
||||
|
||||
export function findMemberByKey(model: ApiModel, packageName: string, containerKey: string, version: string) {
|
||||
const pkg = findPackage(model, packageName)!;
|
||||
const member = (pkg.members[0] as ApiEntryPoint).tryGetMemberByKey(containerKey);
|
||||
|
||||
if (!member) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return ApiNodeJSONEncoder.encode(model, member, version);
|
||||
}
|
||||
|
||||
export function findMember(
|
||||
model: ApiModel,
|
||||
packageName: string,
|
||||
memberName: string | undefined,
|
||||
version: string,
|
||||
): ReturnType<typeof ApiNodeJSONEncoder['encode']> | undefined {
|
||||
if (!memberName) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const pkg = findPackage(model, packageName)!;
|
||||
const member = (pkg.members[0] as ApiEntryPoint).findMembersByName(memberName)[0];
|
||||
|
||||
if (!member) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return ApiNodeJSONEncoder.encode(model, member, version);
|
||||
}
|
||||
6
apps/website/src/util/search.ts
Normal file
6
apps/website/src/util/search.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import MeiliSearch from 'meilisearch';
|
||||
|
||||
export const client = new MeiliSearch({
|
||||
host: 'https://search.discordjs.dev',
|
||||
apiKey: 'b51923c6abb574b1e97be9a03dc6414b6c69fb0c5696d0ef01a82b0f77d223db',
|
||||
});
|
||||
Reference in New Issue
Block a user