DJS Bot Template v2022.704.0 released!
Tags: discord, typescript, node, news
Published: 2022-07-04 14:52:14

**Version 2022.704.0 has been released!**

- Update dependencies
- Update readme (features)
- New error process logger ([e91d811](https://github.com/twiistrzdev/djs-bot-template/commit/e91d81146f99982c5061330389c82d74dc2fa9c7)):
```typescript
...
import logger from './utils/logger.js';

...

process.on(`rejectionHandled`, (error) => logger.error(error));
process.on(`unhandledRejection`, (error) => logger.error(error));
process.on(`uncaughtException`, (error) => logger.error(error));
```
- New [commit convention](https://github.com/twiistrzdev/djs-bot-template/blob/main/.github/COMMIT_CONVENTION.md) ([8d6fa78](https://github.com/twiistrzdev/djs-bot-template/commit/8d6fa78230acf74b1b4b529837c69ffb6671acc8))
- New select menu ([94dbaae](https://github.com/twiistrzdev/djs-bot-template/commit/94dbaaebd283a9c062d021fd8c79f8fb64d2506d)):
```typescript
import { Client, Interaction } from 'discord.js';
import { inject, injectable } from 'tsyringe';
import type { EventInterface } from '../client/interfaces/event.js';
import type { InteractionInterface } from '../client/interfaces/interaction.js';
import { INTERACTIONS } from '../client/tokens.js';
import logger from '../utils/logger.js';

@injectable()
export default class SelectMenuInteractionCreateEvent implements EventInterface {
	public name = `Select Menu Interaction Create`;
	public event = `interactionCreate`;

	public constructor(
		private readonly client: Client<true>,
		@inject(INTERACTIONS) private readonly interactions: Map<string, InteractionInterface>,
	) {}

	public execute() {
		this.client.on(this.event, async (interaction: Interaction<`cached`>) => {
			try {
				if (!interaction.isSelectMenu()) {
					return;
				}

				const menu_ = this.interactions.get(interaction.customId);

				if (!menu_) {
					return;
				}

				await menu_.execute(interaction);
			} catch (e) {
				const error = e as Error;
				logger.error(error, error.message);
			}
		});
	}
}
```
```typescript
@@ -0,0 +1,22 @@
import type { SelectMenuInteraction } from 'discord.js';
import type { InteractionInterface } from '../client/interfaces/interaction.js';
import logger from '../utils/logger.js';

export default class ExampleSelectMenuInteraction implements InteractionInterface {
	public readonly name = `Example Select Menu`;
	public readonly customId = `selectMenuId`;

	public async execute(interaction: SelectMenuInteraction<`cached`>) {
		try {
			const values_ = interaction.values;

			await interaction.reply({
				content: `${values_.join(`\n`)}`,
				ephemeral: true,
			});
		} catch (e) {
			const error = e as Error;
			logger.error(error, error.message);
		}
	}
}
```
- Fixed eslint linter pattern ([0d4f92f](https://github.com/twiistrzdev/djs-bot-template/commit/0d4f92f015def9ada5c4e0001323dd0985943dcb))
- Fixed nullish or undefined in command-embed ([329be04](https://github.com/twiistrzdev/djs-bot-template/commit/329be0480b474916950cceda54e11154bee0d5e3)):
```typescript
@@ -8,16 +8,18 @@ import config from '../../utils/config.js';
 * @returns {EmbedBuilder}
 */
export function exampleCommandEmbed(interaction: ChatInputCommandInteraction<`cached`>): EmbedBuilder {
	const options_ = interaction.options;

	const string_: string = options_.getString(`string`)!;
	const integer_: string = options_.getInteger(`integer`)?.toString() ?? `n/a`;
	const number_: string = options_.getNumber(`number`)?.toString() ?? `n/a`;
	const boolean_: string = options_.getBoolean(`boolean`)?.toString() ?? `n/a`;
	const user_: string = options_.getUser(`user`)?.toString() ?? `n/a`;
	const member_: string = options_.getMember(`user`)?.toString() ?? `n/a`;
	const channel_: string = options_.getChannel(`channel`)?.toString() ?? `n/a`;
	const role_: string = options_.getRole(`role`)?.toString() ?? `n/a`;
	const mentionable_: string = options_.getMentionable(`mentionable`)?.toString() ?? `n/a`;
	const choice_: string = options_.getString(`choice`) ?? `n/a`;

	return new EmbedBuilder()
		.setColor(config.color.primary)
	@@ -29,12 +31,12 @@ export function exampleCommandEmbed(interaction: ChatInputCommandInteraction<`ca
			{ name: `String`, value: `${string_}`, inline: true },
			{ name: `Integer`, value: `${integer_}`, inline: true },
			{ name: `Number`, value: `${number_}`, inline: true },
			{ name: `Boolean`, value: `${boolean_}`, inline: true },
			{ name: `User`, value: `${user_}`, inline: true },
			{ name: `Member`, value: `${member_}`, inline: true },
			{ name: `Channel`, value: `${channel_}`, inline: true },
			{ name: `Role`, value: `${role_}`, inline: true },
			{ name: `Mentionable`, value: `${mentionable_}`, inline: true },
			{ name: `Choice`, value: `${choice_}`, inline: true },
		);
}
```

- Refactor builders ([f307e48](https://github.com/twiistrzdev/djs-bot-template/commit/f307e484bf7570837e297d3ae2d06e9038b3d96c))
- Refactor event names ([da6adeb](https://github.com/twiistrzdev/djs-bot-template/commit/da6adeb61241f1ee1a447e8d995e250dc2cf4382))

The full changelog is available on GitHub: [2022.704.0](https://github.com/twiistrzdev/djs-bot-template/releases/tag/2022.704.0)