Discord Bot設定

1096 ワード

準備物
1.ディスコチャンネル
2.ディスコ開発者サイト権限
ディスコ公式文書
https://discord.com/oauth2/authorize?client_id=775985373296984085&scope=bot

>>>npm i discord.js


const client = new Discord.Client()
// 준비물 2번 링크의 Bot에서 Token을 복사한다
client.login("Nzc1OTg1*******2OTg0MDg1.X6uSsg.1wEoF0Kz1eS_IiUGvxNcFB1PcGc")

client.on("ready", readyDiscord)

const readDiscord = () => {
	console.log("❤")
}

client.on("message", gotMessage)

const gotMessage = (msg) =>{

	console.log(msg.content)
    	if (msg.channel.id == "775986*******0634891" && msg.content === "test") {
    
    	//msg.reply("test activated!")
        msg.channel.send("test activated!")
    }
}