Skip to content

Instantly share code, notes, and snippets.

View svemat01's full-sized avatar

Jakob Helgesson svemat01

View GitHub Profile
@svemat01
svemat01 / autoComplete.md
Last active January 16, 2022 00:33
Discord.JS AutoComplete Quick docs help

AutoComplete DJS v13.3.0

What is autoComplete?

"Autocomplete is basically choices but dynamic. every time the user presses a key in an autocomplete option, the bot gets an event and it can respond with what strings it wants discord to display as choices instead of having the choices be static." - Urcute#3119 on Discord

How do we use it?

For this guide, our command will be named autocomplete, this is not some built in command.

Prepare option for autocomplete

Before we can start to recieve autocomplete events on an option, we have to actually tell discord that we want it.

@svemat01
svemat01 / handlers-AutoCompleteHandler.ts
Created May 17, 2023 17:38
Typescript bot types/handlers
import { Interaction } from 'discord.js';
import { slashCommands } from './SlashHandler';
export const autoCompletes = slashCommands.filter(
(command) => command.autoComplete
); // Auto load commands from SlashHandler but only include them if they have an autocomplete function
export const handleAutoComplete = async (
interaction: Interaction

Components

Train Task (DATA)

The data for what action should be taken by the system. Exists in two different types, collection and delivery.

Collection

Contains the station name and a rough estimate of how many items are going to be picked up.

Delivery

Contains the station name and a list of items to be picked up

Example type implementation