2017-09-28 1 views
-4

私は不協和音のボットを作っているのですが、どのようにランダムなテキスト行を選択して出力するのかと思っていましたか?ランダムな線を選択して出力します

私はこれと同じように動作するコマンドを望みます。また、私はあなたがこのような何かを行うことができますC#

Commands[ "Joke" ] = { 
    oplevel:0, 
    allowed_channels: 'all', 
    allowed_servers: 'all', 
    cooldown: 'none', 
    fn: function(bot, params, msg, msgServer, serverRoles, authorRoles) { 
    var answers = []; 
    answers.push({ 
     message: "Q: What does a dum call a dumpster? A: Bed and Breakfast" 
    }) 
    answers.push({ 
     message: Q: What did the doughnut say to the loaf of bread? A: If I had that much dough, I wouldn't be hanging around this hole." 
    }) 

    answers.push({ 
     message: "What does a dum call a dumpster. Bed and Breakfast" 
    }) 
    answers.push({ 
     message: "Q: What did the doughnut say to the loaf of bread? A: If I had that much dough, I wouldn't be hanging around this hole." 
    }) 
    answers.push({ 
     message: "Q: What do you call cheese that isnt yours? A: Nacho cheese" 
    }) 
+1

はSOへようこそ。このサイトはコード作成サービスではなく、完全なソリューションを提供するためのものではありません。ユーザーは、途中で特定のプログラミング問題を解決するのに役立つために、ここにいくつかの努力とコードを示すことが期待されます。もう何か試しましたか?お読みください:https://stackoverflow.com/help/asking –

答えて

1

の基本を知っている:

int index = random.Next(answers.Count); 
var answer = answers[index]; 
return answer; 
関連する問題