● /problem
/problem은 문제를 찾아주는 명령어로 개발했다.
이미 Sloved.AC봇에서 지원하는 명령어고 더 퀄리티가 높지만 쉬운 거부터 구현했다.
client.on('messageCreate', (msg) => {
if (msg.content.startsWith('/problem')) {
const num= msg.content.slice('/problem'.length).trim();
msg.reply(`문제 링크: https://www.acmicpc.net/problem/${num}`);
}
});
msg문자열을 받고 msg문자열이 /problem으로 시작한다면 뒤에 문자열을 num에 저장하고 GET방식으로 붙이기만 하면 간단하게 구현이 된다.
● 실행
'Programming Project > Solved.AC Discord Bot' 카테고리의 다른 글
Discord Bot 만들기 - 05 /workbook_user (0) | 2024.03.06 |
---|---|
Discord Bot 만들기 - 04 /workbook (0) | 2024.03.05 |
Discord Bot 만들기 - 03 /step (0) | 2024.03.02 |
Discord Bot 만들기 - 02 /user (0) | 2024.03.01 |
Discord Bot 만들기 - 00 (0) | 2024.02.29 |