discord.js-selfbot-v13/examples/SlashCommand.md
2024-02-17 17:50:50 +07:00

3.6 KiB

Slash command

TextBasedChannel.sendSlash(
    user: BotId (Snowflake) | User (User.bot === true),
    commandName: 'command_name [sub_group] [sub]',
    ...args: (string|number|boolean|FileLike|undefined)[],
): Promise<Message<true> | Modal>

Basic

Demo

image

Code

await channel.sendSlash('bot_id', 'aiko')

Sub Command / Sub Group

Demo

image

Code test

await channel.sendSlash('450323683840491530', 'animal chat', 'bye')

Attachment

Demo

image

Code test

const { MessageAttachment } = require('discord.js-selfbot-v13')
const fs = require('fs')
const a = new MessageAttachment(fs.readFileSync('./wallpaper.jpg') , 'test.jpg') 
await message.channel.sendSlash('718642000898818048', 'sauce', a)

Result

image

Skip options

Demo Command

image

image

image

image

Code

	const channel = client.channels.cache.get('channel_id');
	const response = await channel.sendSlash(
		'bot_id',
		'image make',
		'MeinaMix - v11',
		'Phone (9:16) [576x1024 | 810x1440]',
		'2', // String choices, not number
		undefined, // VAE
		undefined, // sdxl_refiner
		undefined, // sampling_method,
		30,
	);
	// Submit Modal
	if (!response.isMessage) { // Modal
		response.components[0].components[0].setValue(
			'1girl, brown hair, green eyes, colorful, autumn, cumulonimbus clouds',
		);
		response.components[1].components[0].setValue(
			'(worst quality:1.4), (low quality:1.4), (normal quality:1.4), (ugly:1.4), (bad anatomy:1.4), (extra limbs:1.2), (text, error, signature, watermark:1.2), (bad legs, incomplete legs), (bad feet), (bad arms), (bad hands, too many hands, mutated hands), (zombie, sketch, interlocked fingers, comic, morbid), cropped, long neck, lowres, missing fingers, missing arms, missing legs, extra fingers, extra digit, fewer digits, jpeg artifacts',
		);
		await response.reply();
	}

Receive messages after bot has replied {botname} is thinking...

aiko-chan-ai/discord.js-selfbot-v13#1055 (comment)

image

const channel = client.channels.cache.get('id');
channel
	.sendSlash('289066747443675143', 'osu', 'Accolibed')
	.then(async (message) => {
		if (message.flags.has('LOADING')) { // owo is thinking...
			return new Promise((r, rej) => {
				let t = setTimeout(() => rej('timeout'), 15 * 60 * 1000); // 15m (DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE)
				message.client.on('messageUpdate', (_, m) => {
					if (_.id == message.id) {
						clearTimeout(t);
						r(m);
					}
				});
			});
		} else {
			return Promise.resolve(message);
		}
	})
	.then(console.log);