Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature v0.3/스케줄 #21

Merged
merged 3 commits into from
Sep 16, 2024
Merged

Conversation

mantaGIT
Copy link
Owner

@mantaGIT mantaGIT commented Sep 16, 2024

Feature v0.3

버튼 상호작용으로 전체 스케줄을 탐색할 수 있도록 기존 명령어를 수정합니다. 또한 변경된 명령어 공지를 위한 새로운 명령어를 추가합니다.

작업 내용 요약

  • /현재스케줄 명령어 응답에 이전 스케줄 버튼을 추가하여 사용자가 이전/다음 스케줄을 탐색할 수 있도록 합니다.
  • 기존 명령어 이름 /현재스케줄을 명령어 동작 성격에 맞도록 /스케줄로 변경합니다.
  • 명령어가 변경됨을 사용자에게 알리기 위해 사용 가능한 봇 명령어 리스트를 보여주는 명령어 /만타봇을 추가합니다.

작업 내용

버튼 상호작용 추가

/현재스케줄 명령어 응답에 이전 스케줄 버튼 상호작용을 추가 구현합니다. 그리고 해당 명령어 이름을 /스케줄로 변경합니다.

Important

모바일로 음성 채널 내 채팅창에서 /오픈 명령어 사용 시 메뉴바가 선택되지 않는 문제가 발견되었습니다.

따라서 버튼으로도 탐색 기능을 구현하여, 메뉴바를 사용할 수 없는 사용자도 스케줄 탐색 기능을 사용할 수 있도록 합니다.

  • 기존의 다음 스케줄 확인하기 버튼 라벨을 다음 스케줄로 변경하고, 이전 스케줄 버튼을 추가 구현합니다.
// 새로운 버튼 추가
const prev = new ButtonBuilder()
  .setCustomId('prev')
  .setLabel('이전 스케줄')
  .setStyle(ButtonStyle.Primary)
  .setDisabled(true);

// 기존 버튼 변경
const next = new ButtonBuilder()
  .setCustomId('next')
  .setLabel('다음 스케줄')
  .setStyle(ButtonStyle.Primary);

const actionRow = new ActionRowBuilder()
  .addComponents(prev, next);

const response = await interaction.editReply({
  embeds: schedEmbed.embeds,
  files: schedEmbed.files,
  components: [ actionRow ],
});
  • 버튼 ID로 구분하여 각 버튼 클릭 시 동작을 처리한다.
const collector = response.createMessageComponentCollector({
  componentType: ComponentType.Button, // 버튼 상호작용 수집
  time: 600_000,
});

collector.on('collect', async i => {
  else if (i.customId === 'prev') { // 이전 스케줄 버튼 클릭 시 처리
    currNode = currNode - 1;
  }
  else if (i.customId === 'next') { // 다음 스케줄 버튼 클릭 시 처리
    currNode = currNode + 1;
  }
}
  • 이전 스케줄 또는 다음 스케줄이 존재하지 않을 경우 버튼을 비활성화한다.
actionRow.components[0].setDisabled(currNode === minNode); // 이전 스케줄 버튼 비활성화
actionRow.components[1].setDisabled(currNode === maxNode); // 다음 스케줄 버튼 비활성화
  • 이전/다음 스케줄 버튼을 통해 전체 스케줄 탐색이 가능해졌으므로 명령어 이름을 /현재스케줄/스케줄로 변경한다.
module.exports = {
  data: new SlashCommandBuilder()
    .setName('스케줄')
    .setDescription('현재 스플래툰3 스케줄 정보를 알려줍니다.')
  // ...
};

봇 정보 출력 명령어 추가

사용자에게 명령어 이름 변경을 알리기 위해 새로운 명령어 /만타봇을 추가한다.

  • commands.json에 현재 사용 가능한 명령어 목록을 작성한다.

    • cmd : 명령어 이름
    • description : 명령어 동작에 대한 간단한 설명
  • 명령어 목록 출력을 위한 임베드 메시지 생성 모듈 botInfo-embedBuilder.js을 작성한다.

  • 해당 명령어 응답은 명령어 사용자만 확안할 수 있도록 설정한다.

await interaction.deferReply({ ephemeral: true });

기타 변경사항

  • vscode에서 코드 작성 시 모듈 임포트가 정상적으로 이루어졌는지 확인하기 위해 상대 경로로 모듈을 가져오도록 한다.

@mantaGIT mantaGIT added the enhancement New feature or request label Sep 16, 2024
@mantaGIT mantaGIT merged commit 9e37eb9 into develop Sep 16, 2024
@mantaGIT mantaGIT deleted the feature-v0.3/slashCommand-schedule branch September 16, 2024 12:37
@mantaGIT mantaGIT restored the feature-v0.3/slashCommand-schedule branch September 18, 2024 07:27
@mantaGIT mantaGIT deleted the feature-v0.3/slashCommand-schedule branch September 18, 2024 07:56
@mantaGIT mantaGIT added the patch Modify existing features label Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request patch Modify existing features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant