2.0.5 • Published 10 months ago

@tb-chan/arguments v2.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

@tb-chan/arguments

This library aims to help with resolving user input string to meaningful data.
For internal uses only.

(For whatever reason I can't type proper Vietnamese in vscode)
For simplicity sake, let's start with a working example.

import { preprocessArgs, processArgs, findCommandInMap } from '@tb-chan/arguments';
import { Client } from 'discord.js';

const client = new Client({
	intents: ['GuildMessages', 'Guilds']
});

const commands = new Map([
	'test',
	{
		name: 'mycommand',
		arguments: {
			foo: {
				name: 'foo',
				type: MessageArgumentType.String,
				required: true
			}
		}
	}
]);

client.on('ready', () => {
	console.log(`${client.user.username} is ready!`);
});

client.on('messageCreate', (message) => {
	const args = preprocessArgs(message.content, 'tb');
	if (!args) return;

	const command = findCommandInMap({ args, commands });
    if (!command) return;

	const result = processArgs({
		command,
		args,
		resolvable: { guild: message.guild, message }
	});

	console.log(result);
});

Pretty complexed, ain't it? Let's break down the code into parts.

2.0.3

10 months ago

2.0.2

11 months ago

2.0.5

10 months ago

2.0.4

10 months ago

2.0.1

11 months ago

2.0.0

11 months ago

1.0.1

1 year ago

1.0.0

2 years ago