LoginSignup
0
0

More than 1 year has passed since last update.

Discord Botの作り方 node.jp

Posted at

はじめに

Discordでオウム返しするbotのコードを載せます。
Discord Botの作り方、まとめ(Node)
をそのまま実行しようとしたら、うまくいきませんでした。そこで、
【discord.js】TypeErrorを解決したい。
を参考に修正したらうまく動きました。
コードの修正箇所以外は、参照元と同じです。

コード

const Discord = require("discord.js");
const client = new Discord.Client({intents: Object.values(Discord.IntentsBitField.Flags)});    
const token = "your token id ";

client.on("ready", ()=> {
    console.log("ready...");
});

client.on("messageCreate",async message => {
    if(message.author.bot){
        return;
    }else{
        let msg = message.content;
        let channel = message.channel;
        let author = message.author.username;
        message.reply(msg)
            .then(message => console.log(`Sent message: ${msg}`))
            .catch(console.error);
        return;
   }
}
);

client.login(token);
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0