본문으로 바로가기

4. DiscordJS client.on 이벤트 정리

category 옛날 글들/DiscordJS 2022. 2. 23. 20:13
반응형
// guildCreate
/* Emitted whenever the client joins a guild.
PARAMETER    TYPE         DESCRIPTION
guild        Guild        The created guild    */
client.on("guildCreate", function(guild){
    console.log(`the client joins a guild`);
});

// guildDelete
/* Emitted whenever a guild is deleted/left.
PARAMETER    TYPE         DESCRIPTION
guild        Guild        The guild that was deleted    */
client.on("guildDelete", function(guild){
    console.log(`the client deleted/left a guild`);
});

guildCreate / guildDelete - 서버 입장/퇴장 시 실행된다.

 

// guildMemberAdd
/* Emitted whenever a user joins a guild.
PARAMETER     TYPE               DESCRIPTION
member        GuildMember        The member that has joined a guild    */
client.on("guildMemberAdd", function(member){
    console.log(`a user joins a guild: ${member.tag}`);
});

guildMemberAdd - 채널에 사람이 들어오면 실행된다.

 

// message
/* Emitted whenever a message is created.
PARAMETER      TYPE           DESCRIPTION
message        Message        The created message    */
client.on("message", function(message){
    console.log(`message is created -> ${message}`);
});

message - 메세지가 생성되면 실행된다.

 

// messageDelete
/* Emitted whenever a message is deleted.
PARAMETER      TYPE           DESCRIPTION
message        Message        The deleted message    */
client.on("messageDelete", function(message){
    console.log(`message is deleted -> ${message}`);
});

messageDelete - 메세지가 삭제되면 실행된다.

 

아래 링크에서 모든 client.on 이벤트들의 내용을 확인할 수 있다.

https://gist.github.com/koad/316b265a91d933fd1b62dddfcc3ff584

 

discordjs-cheatsheet.js

GitHub Gist: instantly share code, notes, and snippets.

gist.github.com

 

반응형