- Create a
.env
file and populate it. Use.env.template
as a reference. - Install
PostgreSQL
andNode.js
. - Create a server with name
postgres
and passwordadmin
. - Create a database called
doctor-large
. - Run
npm install
- Run
npx prisma db push
. - Run
npm run start
.
- Populate the
APPLICATION_ID
key in your.env
file with your application id (the bot's user id). - (Optional) Populate the
GUILD_ID
key in your.env
file with your desired guild's ID. - Run
npm run commands:put
ornpm run commands:clear
to put or clear commands.
- Commands go in
./src/commands/*
- Commands can be nested one layer (
./src/commands/**/*
) - Files can be prefixed with
mod.
to be ignored - Files can be nested at least two layers deep to be ignored
- Commands must export a function
getCommand
that when called returns a function returning an object implementing theCommandExport
type
src/
├── commands/
│ ├── commandFile.ts
│ ├── mod.thisFileWillBeIgnored.ts
│ └── folder/
│ ├── otherCommandFile.ts
│ ├── mod.thisFileWillBeIgnored.ts
│ └── nestedFolder/
│ ├── thisFileWillBeIgnored.ts
│ └── andAnyDeeperNestedFiles.ts
...
// ... Imports
// You need one of `chatInput` and `contextMenu`. You can have both.
const data: CommandData = {
chatInput: {
name: "name",
description: "description",
// rest of data...
},
contextMenu: {
name: "name",
// rest of data...
}
};
const chatInput = async (
interaction: ChatInputCommandInteraction<"cached">
) => {
// `interaction` is untouched.
// (you should deferReply atop this function if applicable)
// Code here...
};
const contextMenu = async (
// You want to type this as either:
// - MessageContextMenuCommandInteraction
// - UserContextMenuCommandInteraction
interaction: ContextMenuCommandInteraction<"cached">
) => {
// `interaction` is untouched.
// (you should deferReply atop this function if applicable)
// Code here...
};
const autocomplete = async (
interaction: AutocompleteInteraction<"cached">
) => {
// Only needed if you have at least one option with `autocomplete: true` .
// Code here...
}
// This *must* be present in every command file.
export const getCommand: () => Command = () => ({
data,
handle: {
// at least one is needed
// `autocomplete` cannot be present without `chatInput`
chatInput,
contextMenu,
autocomplete
}
});
- Events go in
./src/events/*
- Events cannot be nested. Any nested files will be ignored
- Events must export a function
getEvent
that when called returns a function returning an object implementing theEventExport
type - The function
execute
has the parameters as defined in discord.js' documentation (Exception:ready
event, which is given the client)
src/
├── events/
│ ├── eventFile.ts
│ └── folder/
│ ├── thisFileWillBeIgnored.ts
│ └── andAnyDeeperNestedFiles.ts
...
// ... Imports
// Change the params as per discord.js documentation
const execute = (client: Client<true>) => {
// Code here...
};
export const getEvent: () => EventExport = () => ({
// Change this to be the event you want
event: Events.ClientReady,
execute
});