One command multiple users discord python

Hi so I’m making a game on discord using a bot and I’m just starting with a simple rpg kinda game. The system itself is working however it doesn’t allow multiple players to play at once. Only the recent user who sent the command gets to run the program and all other players game stops.

So this is how the logic works:

Import game as game

on_event that a player enters the command
parameters = get player info
run game(parameters)

How do I fix this?

1 Like

You don’t tell us what server or database you are using so it might be difficult for someone to give you specific advice.

In general, you need to create the game and have player messages interact with the game instance. At a high level:

import game as game

game_instance : game

on_ready:
  create game_instance
  create player-tracking

on_message:
  if new-player:
    add to player-tracking
  game_instance(execute-command, player)

Multiple game instances, players joining different games, will require additional tracking and logic.

This might give you some ideas.

The other thing to keep in mind: As long as the following statement doesn’t return:

… then other player’s commands won’t be processed. The game processing needs to be extremely minimal, and/or you need to have multiple bot instances (one per players) interacting with a shared game instance.