Discord Botのために書いたこのコードは動作しません。DiscordボットPythonミニゲームで書かれたループwhile not working
def russian_roulette(author, message):
game_active = True
client.send_message(message.channel, "Russian Roulette game started.6 chambers. 1 loaded.\nType $spin to spin the chamber.\nType $pull to pull the trigger.")
while game_active == True:
if message.content.startswith('$spin'):
chamber = randint(1,6)
client.send_message(message.channel, "%s spins the chambers." % author)
if message.content.startswith('$pull'):
if chamber == 1:
client.send_message(message.channel, "%s pulled the trigger and was not lucky. R.I.P." % author)
game_active = False
else:
client.send_message(message.channel, "%s pulled the trigger and nothing happened." % author)
何が問題なのですか? [Minimal、Complete、Verifiable](http://stackoverflow.com/help/mcve)の例を投稿して、問題が正確に何かを説明してください – James
@Jamesこの関数を実行すると、3行目のコードを次のように出力します。私はそれを期待していましたが、whileループに到達してコマンドに入力すると何も起こりません。 MCVEを入れないと申し訳ありません – Ziepo
私はdiscord APIの仕組みや実装が分かりませんが、メッセージ変数や作成者変数を無限にループして更新することはないように見えます。無限に車輪。無限にループするのではなく、何らかの種類のリスナー関数を作成またはメッセージに添付する必要があります。 – James