async def move_reset(self, message, user: Optional[str]): move_timers = State.get_var(message.guild.id, 'move_timers') if not move_timers: move_timers = defaultdict(lambda: datetime.min) for player in message.mentions: move_timers[player.id] = datetime.min State.set_var(message.guild.id, 'move_timers', move_timers)
async def move(self, message: Message, room: Optional[str]): connections = State.get_config(message.guild.id)['connections'] channel: TextChannel = message.channel destinations = self._list_destinations(connections, channel.name) if not room: destination_list = '\n'.join( destination + (' *(locked)*' if locked else '') for destination, locked in destinations ) await channel.send( ( 'The following destinations are available from here:\n' + destination_list ) if destination_list else 'No destinations are currently available.', delete_after=60*60 ) await message.delete() return for destination, locked in destinations: if destination == room: if locked: await channel.send( f'{room} is currently locked off.', delete_after=60*60 ) await message.delete() return break else: await channel.send( f'Cannot reach {room} from here.', delete_after=60*60 ) return move_timers = State.get_var(message.guild.id, 'move_timers') if not move_timers: move_timers = defaultdict(lambda: datetime.min) time_remaining = ( move_timers[message.author.id] - datetime.now() ).total_seconds() if time_remaining > 0: minutes = time_remaining // 60 await channel.send( 'Must wait ' + ( f'{int(minutes)} minutes' if minutes else f'{int(time_remaining)} seconds' ) + ' before moving again.', delete_after=60*60 ) return connection = self.roleplay.get_connection(channel.name, room) new_channel = await self._move_player( message.author, room, message.channel ) move_timers[message.author.id] = datetime.now() + timedelta( minutes=connection.timer ) State.set_var(message.guild.id, 'move_timers', move_timers) await channel.send(f'{message.author.mention} moves to {room}') await new_channel.send( f'{message.author.mention} moves in from {channel.name}' ) await message.delete()