DJS 봇 템플릿 v2022.704.0 출시!

버전 2022.704.0이 출시되었습니다!
  • 업데이트 종속성
  • 추가 정보 업데이트(기능)
  • 새 오류 프로세스 로거( e91d811 ):

  • ...
    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));
    


  • 새로운 commit convention ( 8d6fa78 )
  • 새 선택 메뉴( 94dbaae ):

  • 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);
                }
            });
        }
    }
    



    @@ -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);
            }
        }
    }
    


  • 고정 에스린트 린터 패턴( 0d4f92f )
  • command-embed에서 null이거나 정의되지 않은 문제를 수정했습니다(329be04).

  • @@ -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 },
            );
    }
    


  • 리팩터 빌더( f307e48 )
  • 이벤트 이름 리팩터링( da6adeb )

  • 전체 변경 로그는 GitHub에서 사용할 수 있습니다. 2022.704.0

    좋은 웹페이지 즐겨찾기