LoginSignup
0
0

More than 3 years have passed since last update.

今までに作ってきた機能すべてを埋め込みメッセージデやって見ようと検証

Posted at

まずは、占い

//占い
client.on('message', message => {
if(message.content === 'r.uranai'){
var array = ["凶 えぇ、、、", "小吉 まあ、がんば", "中吉 普通で草", "吉 おめでと。", "大吉 おめでと。"];
message.channel.send({
  embed: {
    description: array[Math.floor(Math.random() * array.length)],
    color: 16757683,
  }
})
console.log(array[Math.floor(Math.random() * array.length)]);
}
})

こんな感じ。
次にcoinゲーム

//コインゲーム
client.on('message', message => {
if(message.content === 'r.coin'){
var array = ["📀omote 君の勝ち!おめでとう🎉", "💿ura 君の負け...残念😭"];
message.channel.send({
  embed: {
    description: array[Math.floor(Math.random() * array.length)],
    color: 16757683,
  }
})
console.log(array[Math.floor(Math.random() * array.length)]);
}
})

注意点は,:dvd:とかやっても実行はできるけど、めっちゃラグイ。
だから普通に絵文字でやることをオススメ。

//不適切なメッセージのさくじょ
client.on('message',message=>{
 if (message.content.match(/しね|ころす|死ね|殺す|きっしょ|ゴミ|野獣先輩|糞|カス/)) {
   message.channel.send('不適切な表現が含まれていたため、削除しました。');
  message.delete(100)
}
})
client.on('message',message=>{
if (message.content.match(/不適切な表現が含まれていたため、削除しました。/)) {
        message.delete(3000)
   }
})

は、、、どうやろうかお悩み中。埋め込みメッセージのなかみ認識とかわかんない(自分は)
おまけのコーナー

client.on('message',message=>{
  if (message.content.match(/    /)){
    message.channel.send(
      {embed:{
              color:16757683,
              description:'[]()'

      }}
      );
      }});

これの/と/の間に文字を発言すると、[]←のなかの言葉に()←で埋め込みリンクできる🎉
今回はこんなかんじでおわ(ry

0
0
1

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